[英]error UnicodeDecodeError: 'utf-8' codec when reading CSV
I recently download the PISA 2012 Student database from PISA. 我最近从PISA下载了PISA 2012学生数据库。 I follow the instructions and successfully read it on SAS. 我按照说明进行操作,并在SAS上成功阅读。 Then I exported as CSV to read it in Python 3, using proc export, but I keep getting this error when trying to read it in python pandas: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 24: invalid start byte. 然后我导出为CSV以使用proc导出在Python 3中读取它,但是尝试在python大熊猫中读取它时却不断收到此错误:UnicodeDecodeError:'utf-8'编解码器无法解码位置24的字节0xc1:无效起始字节。 What can I do? 我能做什么?
pisa2012_Col=pd.read_csv('Pisasubset2012Col.csv') pisa2012_Col = pd.read_csv('Pisasubset2012Col.csv')
Try using 尝试使用
pisa2012_Col=pd.read_csv('Pisasubset2012Col.csv', encoding = "ISO-8859-1")
Since read_csv
has an encoding option to deal with files in different formats (See python docs ) 由于read_csv
具有编码选项,可以处理不同格式的文件(请参阅python docs )
Thank you both. 谢谢你俩。 It seems to work. 似乎有效。 I read it successfully and until know, variables are responding fine to my calculations. 我读得很成功,直到知道为止,变量对我的计算都响应良好。 Seems SOLVED. 似乎解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.