Revision 9509
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/csvs.py | ||
---|---|---|
177 | 177 |
|
178 | 178 |
class ColInsertFilter(Filter): |
179 | 179 |
'''Adds column(s) to each row |
180 |
@param mk_value(row, row_num) |
|
180 |
@param mk_value(row, row_num) | literal_value
|
|
181 | 181 |
''' |
182 | 182 |
def __init__(self, reader, mk_value, index=0, n=1): |
183 |
if not callable(mk_value): |
|
184 |
value = mk_value |
|
185 |
def mk_value(row, row_num): return value |
|
186 |
|
|
183 | 187 |
def filter_(row): |
184 | 188 |
row = list(row) # make sure it's mutable; don't modify input! |
185 | 189 |
for i in xrange(n): |
Also available in: Unified diff
lib/csvs.py: ColInsertFilter: support using a literal value instead of a function for the mk_value param, since this is the most common use case