angel7170
asked on
Read JSON and Write to CSV using Python
Hello,
We have a JSON file that we are trying to read and put the Key and the values in a CSV file. We are getting an error as below. can someone please help?
Attached is the sample JSON file and the Python code we are using.
Our program Parse_workitem.py accepts 2 arguments one is input_file which is json and the other one is output_file which is csv. When we execute the code as below with both arguments the code is failing with the following error. We are using Python version 2.7.5
./parse_workitem.py --input_file /home/dqadmin/json/work_it ems.json --output_file /home/dqadmin/json/work_it ems.csv
Traceback (most recent call last):
File "./parse_workitem.py", line 66, in <module>
main()
File "./parse_workitem.py", line 54, in main
value = item.get(key, '')
AttributeError: 'unicode' object has no attribute 'get'
Thank you
parse_workitem.py
sample.txt
We have a JSON file that we are trying to read and put the Key and the values in a CSV file. We are getting an error as below. can someone please help?
Attached is the sample JSON file and the Python code we are using.
Our program Parse_workitem.py accepts 2 arguments one is input_file which is json and the other one is output_file which is csv. When we execute the code as below with both arguments the code is failing with the following error. We are using Python version 2.7.5
./parse_workitem.py --input_file /home/dqadmin/json/work_it
Traceback (most recent call last):
File "./parse_workitem.py", line 66, in <module>
main()
File "./parse_workitem.py", line 54, in main
value = item.get(key, '')
AttributeError: 'unicode' object has no attribute 'get'
Thank you
parse_workitem.py
sample.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.