Project

General

Profile

« Previous | Next » 

Revision 1127

union: Added header_num option to select which map's header to use as the output header

View differences:

union
16 16

  
17 17
def main():
18 18
    ignore = opts.env_flag('ignore')
19
    header_num = int(opts.get_env_var('header_num', 0))
20
        # selects which map's header to use as the output header
19 21
    try: _prog_name, map_1_path = sys.argv
20 22
    except ValueError:
21
        raise SystemExit('Usage: env [ignore=1] '+sys.argv[0]
23
        raise SystemExit('Usage: env [ignore=1] [header_num={0|1}] '+sys.argv[0]
22 24
            +' <map_0 map_1 [| '+sys.argv[0]+' map_2]... >union_map')
23 25
    
24 26
    headers = [None]*2
......
39 41
    
40 42
    # Pass through map 0, storing which inputs it defines
41 43
    writer = csv.writer(sys.stdout)
42
    writer.writerow(headers[0])
44
    writer.writerow(headers[header_num])
43 45
    inputs = set()
44 46
    for row in map_0_reader:
45 47
        if row[0] != '': inputs.add(row[0])

Also available in: Unified diff