简体   繁体   English

错误UnicodeDecodeError:读取CSV时出现“ utf-8”编解码器

[英]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.

相关问题 Python 3 CSV 文件给出 UnicodeDecodeError: 'utf-8' 编解码器在打印时无法解码字节错误 - Python 3 CSV file giving UnicodeDecodeError: 'utf-8' codec can't decode byte error when I print UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 1 的字节 0x8b:无效的起始字节,同时在 Pandas 中读取 csv 文件 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte, while reading csv file in pandas Python读取Web CSV-UnicodeDecodeError:将utf-8转换为CSV - Python Reading a Web CSV - UnicodeDecodeError: utf-8 into CSV UnicodeDecodeError:“utf-8”编解码器无法解码字节 0xf8,同时将 sql 转储转换为 csv - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8, while converting sql dump to csv pandas read_csv 在返回 UnicodeDecodeError: 'utf-8' 编解码器的特定行上失败 - pandas read_csv fails on specific row returning UnicodeDecodeError: 'utf-8' codec 错误 UnicodeDecodeError:'utf-8' 编解码器无法解码 position 中的字节 0xff 0:起始字节无效 - error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte 错误 UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 2 中的字节 0xbe:起始字节无效 - error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 2: invalid start byte UnicodeDecodeError:'utf-8'编解码器无法解码 - Python 3 - UnicodeDecodeError: 'utf-8' codec can't decode - Python 3 IMAP 消息获取 UnicodeDecodeError 'utf-8' 编解码器无法解码 - IMAP message gets UnicodeDecodeError 'utf-8' codec can't decode UnicodeDecodeError:“utf-8”编解码器无法解码 position 中的字节 0x80 0:读取文本文件时起始字节无效 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte while reading a text file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM