7/13/2023 0 Comments Python code to convert json to csv![]() ![]() ![]() 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 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. ![]()
0 Comments
Leave a Reply. |