Revision 120
Added by Aaron Marcuse-Kubitza about 13 years ago
join_maps | ||
---|---|---|
20 | 20 |
|
21 | 21 |
# Join map 1 to map 0 |
22 | 22 |
reader = csv.reader(sys.stdin) |
23 |
map_0_in, map_0_out = reader.next()[:2] |
|
24 |
if not map_0_out == map_1_in: raise SystemExit( 'Map error: ' |
|
23 |
writer = csv.writer(sys.stdout) |
|
24 |
cols = reader.next() |
|
25 |
if not cols[1] == map_1_in: raise SystemExit( 'Map error: ' |
|
25 | 26 |
'Map 0 output column name doesn\'t match map 1 input column name') |
26 |
writer = csv.writer(sys.stdout)
|
|
27 |
writer.writerow([map_0_in, map_1_out])
|
|
27 |
cols[1] = map_1_out
|
|
28 |
writer.writerow(cols)
|
|
28 | 29 |
for row in reader: |
29 |
if row[1] in map_1: writer.writerow([row[0], map_1[row[1]]]) |
|
30 |
try: row[1] = map_1[row[1]] |
|
31 |
except KeyError: continue # skip row |
|
32 |
writer.writerow(row) |
|
30 | 33 |
|
31 | 34 |
main() |
Also available in: Unified diff
Added Comments column with Brad's and Aaron's comments to mapping spreadsheets