首页 > 解决方案 > Encoding csv error with Pandas - have to encode one csv file but not the other -both have same encoding

问题描述

I am using pandas to read in csv data to my python script. Both csv files have the same encoding (Windows-1252). However with one of the files I get an error when reading the csv file with pandas, unless I specify the encoding parameters in pd.read_csv().

Does anyone know why I need to specify the encoding in one csv and not the other? Both csv's contain similar data (strings and numbers).

Thank you

标签: pythonpandascsv

解决方案


这只是意味着其中一个文件的字符超出了 0x00 到 0x7F 的范围。只有编码产生影响的最高 128 个值。只需要一个带波浪号的 n 或一个智能引号。


推荐阅读