I have an issue where character with an accent such as the 'ë' in 'Citroën' are being read as 'Citroën' when I open the files in excel.
I suspect the issue is to do with the encoding of the output file.
According to the docs the default encoding for the to_csv
function is 'utf-8'. Try using 'utf-8-sig' instead, i.e.:
df.to_csv('output.csv', index = False, encoding = 'utf-8-sig')
That often does the trick for me.
You can also use utf-16
, it works for me, but if you have a problem with the separator option, do as it follows:
df.to_csv('output.csv', encoding='utf-16', sep='\t', index=False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With