I have written code to read a CSV into a python dictionary, which works fine. I\'m trying to get the dictionary back to a CSV. I have written the following:
d = [{'a': 1, 'b': 2},{'a': 3, 'b': 4}]
with open('csv_file.csv', 'w', newline='\n') as f:
w = csv.DictWriter(f, d[0].keys())
w.writeheader()
for i in d:
w.writerow(i)