Revision 737
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/join | ||
---|---|---|
19 | 19 |
map_1 = {} |
20 | 20 |
stream = open(map_1_path, 'rb') |
21 | 21 |
reader = csv.reader(stream) |
22 |
map_1_in, map_1_out = reader.next()[:2]
|
|
22 |
map_1_cols = reader.next()
|
|
23 | 23 |
for row in reader: |
24 | 24 |
if row[0] != '': map_1[row[0]] = row |
25 | 25 |
stream.close() |
... | ... | |
27 | 27 |
# Join map 1 to map 0 |
28 | 28 |
reader = csv.reader(sys.stdin) |
29 | 29 |
writer = csv.writer(sys.stdout) |
30 |
cols = reader.next() |
|
31 |
if not cols[1] == map_1_in: raise SystemExit('Map error: '
|
|
30 |
map_0_cols = reader.next()
|
|
31 |
if not map_0_cols[1] == map_1_cols[0]: raise SystemExit('Map error: '
|
|
32 | 32 |
'Map 0 output column name doesn\'t match map 1 input column name') |
33 |
cols[1] = map_1_out |
|
34 |
writer.writerow(cols) |
|
33 |
writer.writerow(maps.merge_mappings(map_0_cols, map_1_cols)) |
|
35 | 34 |
for row in reader: |
36 | 35 |
if row[1] != '': |
37 | 36 |
try: out_row = map_1[row[1]] |
Also available in: Unified diff
join: Merge the column labels as well