9/5/2023 0 Comments Json to csv in pythonI know it requires a for loop and if statement to specify the key names later on, but not sure the best way to implement it. The rest is useless information (such as statusCode) or it's duplicated under a different key name (such as profile and userInfo). In the example at the bottom, I only want everything under the following keys: created, emails, and identities. # Export to CSV in the same directory with the original file nameĮxport_csv = df.to_csv (file_path + r'.csv', sep=',', encoding='utf-8', index=None, header=True) # Enter the path to the JSON and the filename without appending '.json'ĭic = json.load(open(file_path + '.json', 'r', encoding='utf-8', errors='ignore'))ĭic_flattened = (flatten(d, '.') for d in dic) Extract certain nested data in the JSON file. I'm converting several JSON files into a CSV using the following code below, it works as intended, but it converts all of the data in the JSON file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |