Revision 2021
Added by Aaron Marcuse-Kubitza over 12 years ago
subtract | ||
---|---|---|
6 | 6 |
# - Entries whose input and output maps to the same non-empty value in A1 |
7 | 7 |
|
8 | 8 |
import csv |
9 |
import operator |
|
9 | 10 |
import os.path |
10 | 11 |
import sys |
11 | 12 |
|
... | ... | |
26 | 27 |
if compare_col_nums == []: |
27 | 28 |
compare_col_nums = None # list_subset() value for all columns |
28 | 29 |
|
29 |
def compare_on(row): return tuple(util.list_subset(row, compare_col_nums)) |
|
30 |
def compare_on(row): |
|
31 |
return tuple(util.list_subset(row, compare_col_nums, default=None)) |
|
30 | 32 |
|
31 | 33 |
headers = [None]*2 |
32 | 34 |
|
... | ... | |
41 | 43 |
if row[0] != '': |
42 | 44 |
input_cols.add(row[0]) |
43 | 45 |
compare_cols.add(compare_on(row)) |
44 |
if row[1] != '': map_[row[0]] = row[1] |
|
46 |
if reduce(operator.and_, (v == '' for v in row[1:])): # all empty |
|
47 |
map_[row[0]] = row[1] |
|
45 | 48 |
stream.close() |
46 | 49 |
|
47 | 50 |
# Open map 0 |
Also available in: Unified diff
subtract: Support "ragged rows" that have fewer columns than the specified column numbers