Convert JSON to CSV Using Python

PHOTO EMBED

Sun Sep 24 2023 01:29:37 GMT+0000 (Coordinated Universal Time)

Saved by @OperationsBGSC #python

import csv

import json



# Open the JSON file

with open('data.json') as json_file:

    data = json.load(json_file)



# Create a new CSV file and write the data

with open('data.csv', 'w', newline='') as csv_file:

    writer = csv.DictWriter(csv_file, fieldnames=data[0].keys())

    writer.writeheader()

    for row in data:

        writer.writerow(row)
content_copyCOPY

https://codebeautify.org/blog/convert-json-to-csv-using-python/