CSV opens fine in LibreOffice but accents are garbage in Excel
My class list has names like José and Zoë. I write it from Python with open("list.csv", "w", encoding="utf-8") and LibreOffice shows it correctly. On the school computers with Excel it shows José.
What did I do wrong?
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
3 replies
Nothing wrong, Excel is guessing. Without a BOM it assumes the Windows codepage when you double click a CSV. Use encoding="utf-8-sig" and it'll write the three BOM bytes at the start, and Excel will then read it as UTF-8.
Don't use it for files other programs read, some of them treat the BOM as part of the first column name.
And keep newline="" on that open() call if you're using the csv module.
That fixed it, thanks both! José is back.