Revision 4626
Added by Aaron Marcuse-Kubitza over 12 years ago
translate | ||
---|---|---|
18 | 18 |
stream = open(dict_path, 'rb') |
19 | 19 |
reader = csv.reader(stream) |
20 | 20 |
reader.next() # skip header |
21 |
for from_, to in reader: dict_[from_] = to
|
|
21 |
for row in reader: dict_[row[0]] = row[1]
|
|
22 | 22 |
stream.close() |
23 | 23 |
|
24 | 24 |
# Translate input |
Also available in: Unified diff
canon, translate, filter_out_ci: Support vocabularies/dictionaries with additional columns in addition to the functional column(s) used by the program. These columns can contain comments, etc. This was not originally supported because Python 2's iterable unpacking only supports "an iterable with the same number of items as there are targets in the target list" (http://docs.python.org/reference/simple_stmts.html#assignment-statements). We now use numeric array indexes instead to get around this limitation, and for consistency with other map-manipulation scripts.