Revision 7448
Added by Aaron Marcuse-Kubitza almost 12 years ago
translate | ||
---|---|---|
1 | 1 |
#!/usr/bin/env python |
2 |
# Translates a spreadsheet column using a dictionary.
|
|
2 |
# Translates a spreadsheet column using a thesaurus.
|
|
3 | 3 |
# The column header is also translated. CSVs without a header are supported. |
4 | 4 |
# Unrecognized names are left untouched, permitting successive runs on different |
5 |
# dictionaries.
|
|
5 |
# thesauruses.
|
|
6 | 6 |
# Case- and punctuation-sensitive. (Use canon first for case-insensitivity.) |
7 | 7 |
|
8 | 8 |
import csv |
... | ... | |
11 | 11 |
def main(): |
12 | 12 |
try: _prog_name, col_num, dict_path = sys.argv |
13 | 13 |
except ValueError: raise SystemExit('Usage: '+sys.argv[0] |
14 |
+' <in col# dict [| '+sys.argv[0]+' col# dict_2]... >out')
|
|
14 |
+' <in col# thesaurus [| '+sys.argv[0]+' col# thesaurus_2]... >out')
|
|
15 | 15 |
col_num = int(col_num) |
16 | 16 |
|
17 |
# Get dict
|
|
17 |
# Get thesaurus
|
|
18 | 18 |
dict_ = {} |
19 | 19 |
stream = open(dict_path, 'rb') |
20 | 20 |
reader = csv.reader(stream) |
Also available in: Unified diff
translate: Changed dictionary to thesaurus, since the map used actually has synonyms rather than definitions