Revision 3807
Added by Aaron Marcuse-Kubitza over 12 years ago
bin/review | ||
---|---|---|
1 | 1 |
#!/usr/bin/env python |
2 | 2 |
# Converts a map spreadsheet to human-readable (but machine unusable) form |
3 |
# Usage: self <in_map >out_map |
|
3 |
# Usage: self [col_num...] <in_map >out_map
|
|
4 | 4 |
|
5 | 5 |
import csv |
6 | 6 |
import re |
... | ... | |
46 | 46 |
return xpath |
47 | 47 |
|
48 | 48 |
def main(): |
49 |
col_nums = sys.argv[1:] |
|
50 |
if col_nums == []: col_nums = range(2) |
|
51 |
col_nums = map(int, col_nums) # 0-based |
|
52 |
|
|
49 | 53 |
# Convert map |
50 | 54 |
reader = csv.reader(sys.stdin) |
51 | 55 |
writer = csv.writer(sys.stdout) |
52 | 56 |
writer.writerow(reader.next()) |
53 | 57 |
for row in reader: |
54 |
for i in xrange(2): row[i] = cleanup(row[i])
|
|
58 |
for i in col_nums: row[i] = cleanup(row[i])
|
|
55 | 59 |
writer.writerow(row) |
56 | 60 |
|
57 | 61 |
main() |
Also available in: Unified diff
review: Support limiting the XPath simplifying to custom columns, rather than always the first two