My team uses a Ç (ALT 0199) as a separator in their CSV files. I’m trying to replicate using this in Pandas, but not having any luck. Any guidance is appreciated as I’m new to Pandas
results.to_csv('filename.csv', encoding='latin1', sep='Ç')
SyntaxError: (unicode error) ‘utf-8’ can’t decode byte 0xc7
>Solution :
The fact that you get a SyntaxError seems to indicate that Python can’t even read your program, let alone run it. It would seem that your Python source code file is encoded as iso-8859-1 (a.k.a latin-1), but Python thinks it’s in the default utf-8 encoding. Try adding a comment at the beginning of the file:
# -*- coding: iso-8859-1 -*-
See the Lexical Analysis chapter of the language reference for details.
Alternatively, avoid using "funny" characters in the source code, and do
results.to_csv(blabla, sep='\u00c7')
(And seriously, if you need to use funny separators in your "C"SV:s, then something, somewhere, isn’t using a proper CSV parser. Chaos awaits in your future…)