evidens / json2csv

Converts JSON files to CSV (pulling data from nested structures). Useful for Mongo data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json data accessed via facebook api

sanjayb678 opened this issue · comments

I'm getting this error when i try to convert my json file to csv.

Traceback (most recent call last):
File "json2csv.py", line 120, in
loader.write_csv(filename=outfile)
File "json2csv.py", line 71, in write_csv
writer.writeheader()
AttributeError: DictWriter instance has no attribute 'writeheader'

need some help

Which version of Python are you using? writeheader was only added in 2.7 if you're using an older version you'll have to upgrade https://docs.python.org/2/library/csv.html#csv.DictWriter.writeheader

If you install the optional unicodecsv dependency, that library has the method defined.

Thanks for the revert. I'm converting data extracted from facebook in JSON format to CSV and did download the package json2csv. But i got an error when i installed "pip install -r requirements.txt", is that causing some issues ???
The error i get is:
Command "/usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-giCPqH/unicodecsv/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-i5f5zO-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-giCPqH/unicodecsv

Your issue is outside the scope of this tool.
You will probably want to install the unicodecsv library if you're dealing with FB data, and it appears there's an issue: either with your setuptools or with your Python installation.

I would try pip install unicodecsv on its own and see if you get more output about the error. It would be a good idea to upgrade to Python 2.7 if you can, it's been out for several years.