json2csv icon indicating copy to clipboard operation
json2csv copied to clipboard

list indices must be integers, not str

Open ernohorvath opened this issue 9 years ago • 1 comments

Tried gen_outline.py and failed. Got the following error, as I'm not a developer I have no clue what have I missed.. Traceback (most recent call last): File "gen_outline.py", line 85, in main() File "gen_outline.py", line 75, in main outline = make_outline(args.json_file, args.each_line, args.collection) File "gen_outline.py", line 50, in make_outline key_map = gather_key_map(iterator) File "gen_outline.py", line 31, in gather_key_map for d in iterator: File "gen_outline.py", line 26, in coll_iter for obj in data[coll_key]: TypeError: list indices must be integers, not str

It's a standard mongodb json extract.

ernohorvath avatar Aug 31 '16 21:08 ernohorvath

For MongoDB you need to specify --each-line (JSON usually only has one object per file but Mongo breaks that rule and puts a bunch in the same file).

python gen_outline.py --each-line <yourfile>
python json2csv.py --each-line <yourfile> <outline file from previous step>

Hope that helps. I'll update the README with a call-out for Mongo so it's clearer to the next person.

evidens avatar Sep 01 '16 19:09 evidens