Use delimiter used by default in Excel.
Python : .csv doesn't open well in MS excel
-
04-06-2022 - |
Question
I write a csv
using python's unicodecsv
module like this :
with open(self.FILENAME, 'wb') as csvfile:$
writer = unicodecsv.writer(csvfile, delimiter='|',quotechar='"')
write_func(writer)
However opening this file directly in excel causes problems. The data doesn't seem to be written correctly. I get missing columns in excel and records overflowing to the other rows. It works fine in Libreoffice
Is there anything that should be taken care of while writing to csv if I have to use that file in excel
?
Solution
OTHER TIPS
I'd advised to use openpyxl (or similar) Python library to create xlsx files instead. Then it will work with both LibreOffice and MS Excel. Opening of CSVs on Excel is made hard, and subtle details change from version to version.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow