athomellka.blogg.se

Python code to convert json to csv
Python code to convert json to csv




python code to convert json to csv

Thank you in advance! Any tips how to improve my code and make it more efficient are very welcome. | attributes_gender_numeric | attributes_gender_value | attributes_email_value | change_id | change_seen | Therefore, I would like to have output like this: | _id.id | device.browser |. I have to make it generalisable because the number of keys in attributes and change. I cannot figure out how to make it generic so I do not use dictionary keys ( numeric, id, name) and values while creating table. My problem is that I would like to include the nested arrays into the cvs, so I have to flatten them. My current output looks something like this: | _id.id | device.browser | device.category | device.os |. #Excluding nested arrays from json dictionary #Excluding nested arrays from keys - hard coded -> IMPROVE With following code (here I exclude the nested parts): import jsonįrom pandas.io.json import json_normalize

python code to convert json to csv

To do so I started with loading the json and then transformed it in a way that prints out nice output with json_normalize, then using pandas package I output the normalised parts into cvs. I am very new to Python and I am struggling with converting nested json file into cvs.






Python code to convert json to csv