I'm trying to write a dictionary to csv file in python.
I'm using following solution:
Export a simple Dictionary into Excel file in python
However when i write to file in a following manner:
for key, value in dict1.iteritems():
writer.writerow([key, value])
The key and the value from dictionary are stored in single column for each item in dictionary. I would like key to be stored in first column and value to be stored in second column and to assign headers to the columns if possible. Can anyone help?
writer. Is it identical to the linked question?.csvand Excel is opening it (I tried.xlsxbut Excel says the file is corrupt so I'm not sure about this one) or you've definedwriterto use a different delimiter e.g.;which Excel is not configured to read, or you've changed the standard delimiter in Excel so that it isn't recognising,.