I have problem when i convert json file to csv
i convert my csv file to json and it work
but when i convert json file to csv file it don't work!
HERE MY PYTHON CODE
with open('orders.json') as json_file:
data = json.load(json_file)
order_data = data['orders']
# now we will open a file for writing
data_file = open('data_file.csv', 'w')
# create the csv writer object
csv_writer = csv.writer(data_file)
# Counter variable used for writing
# headers to the CSV file
count = 0
for ord in order_data:
if count == 0:
# Writing headers of CSV file
header = ord.keys()
csv_writer.writerow(header)
count += 1
# Writing data of CSV file
csv_writer.writerow(ord.values())
data_file.close()
and the output is like this
there null row on the csv file how to handle this problem?
and here the json file
Copyright Notice:Content Author:「gemma」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71938580/i-want-to-convert-json-file-to-csv-file-using-pyhton