Revision 14617
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/lib/csvs.py | ||
---|---|---|
305 | 305 |
'''reads parsed JSON data as row tuples |
306 | 306 |
@param json_data [{'col': 'value', __}, __] |
307 | 307 |
''' |
308 |
def __init__(self, json_data, col_order=[]): |
|
309 |
def preprocess(json_row): return json_row |
|
310 |
MultiFilter.__init__(self, row_dict_to_list_reader(Filter(preprocess, |
|
308 |
def __init__(self, json_data, col_order=[], array_sep=None): |
|
309 |
def conv_value(value): |
|
310 |
if lists.is_seq(value): |
|
311 |
assert array_sep != None # required if there is any array data |
|
312 |
return array_sep.join(value) |
|
313 |
else: return value |
|
314 |
def conv_values(tuple_row): return map(conv_value, tuple_row) |
|
315 |
MultiFilter.__init__(self, Filter(conv_values, row_dict_to_list_reader( |
|
311 | 316 |
iter(json_data)))) |
Also available in: Unified diff
lib/csvs.py: JsonReader: added support for values that are arrays