[英]Which encoding to open utf-8 csv file in Python which opens correctly in Excel with Windows (ANSI)
I have a database export in csv which is UTF8
encoded. 我在csv中使用
UTF8
编码进行数据库导出。 When i open it in Excel, i have to choose Windows (ANSI)
at opening in order to see special characters correctly displays (é, è, à for instance). 当我在Excel中打开它时,我必须在打开时选择
Windows (ANSI)
才能正确显示特殊字符(例如,é,è,à)。 If i use Python pandas to open csv file specifying UTF8
encoding, it does not seem to get correctly decoded (é,è,à characters are not displayed correctly): 如果我使用Python熊猫打开指定
UTF8
编码的csv文件,它似乎无法正确解码(é,è,à字符未正确显示):
StŽphanie
FrŽdŽrique
GŽraldine
How should i correctly read this file with Python pandas ? 我应该如何使用Python pandas正确读取此文件? Thanks a lot
非常感谢
This encoding is Windows-1252, referred to as "cp1252"
by Python. 此编码为Windows-1252,在Python中称为
"cp1252"
。 ANSI is a misnomer; ANSI是用词不当; it's completely unrelated to the organisation.
它与组织完全无关。
Try: 尝试:
with open("filepath.csv", encoding="cp1252") as f:
pandas.read_csv(f)
The solution was actually to use latin1
encoding in my case: 解决方案实际上是在我的情况下使用
latin1
编码:
Stéphanie
Frédérique
Géraldine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.