I have a list of returned values from a json file
2020-09-08 - 11290
2020-09-09 - 11290
2020-09-10 - 11290
2020-09-11 - 12290
I saved above values to a variable "data". These values are returned from a json list by using print(data)
print(f"{node['X']} - {node['Y']}") #print(data)
I want this list of returned values into a csv file with a header "X" and "Y"
fieldnames = ['X', 'Y']
with open('mydata.csv', 'w') as f:
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(chain.from_iterable(data))
This piece of code is returning empty data with just two headers given "X" and "Y" It would be great if i get a suggestion or a solution with some example. Thanks for the help!