Revision 1769
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/union | ||
---|---|---|
9 | 9 |
|
10 | 10 |
import maps |
11 | 11 |
import opts |
12 |
import util |
|
12 | 13 |
|
13 | 14 |
def main(): |
14 | 15 |
ignore = opts.env_flag('ignore') |
15 |
header_num = int(opts.get_env_var('header_num', 0))
|
|
16 |
header_num = util.cast(int, opts.get_env_var('header_num'))
|
|
16 | 17 |
# selects which map's header to use as the output header |
17 | 18 |
try: _prog_name, map_1_path = sys.argv |
18 | 19 |
except ValueError: |
... | ... | |
38 | 39 |
|
39 | 40 |
# Pass through map 0, storing which inputs it defines |
40 | 41 |
writer = csv.writer(sys.stdout) |
41 |
writer.writerow(headers[header_num])
|
|
42 |
writer.writerow(maps.merge_headers(*headers, prefer=header_num))
|
|
42 | 43 |
inputs = set() |
43 | 44 |
for row in map_0_reader: |
44 | 45 |
if row[0] != '': inputs.add(row[0]) |
Also available in: Unified diff
union: Use new maps.merge_headers() to write properly combined header