[英]Python Pandas CParserError Error tokenizing data
I am trying to use pandas to read a .csv file 我正在尝试使用熊猫读取.csv文件
df = pd.read_csv('ChildCareCenters06252017.csv')
and then I get this error 然后我得到这个错误
CParserError: Error tokenizing data. C error: Expected 31 fields in line 3, saw 42
I have read the pandas docs and I have gone through other stack posts similar to this but no solutions have worked. 我已经阅读了pandas文档,并且浏览了与此类似的其他堆栈文章,但是没有解决方案。
I am going to this link https://secure.dss.ca.gov/CareFacilitySearch/DownloadData and then clicking child care centers and then saving that data and trying to read. 我将转到此链接https://secure.dss.ca.gov/CareFacilitySearch/DownloadData ,然后单击托儿中心,然后保存该数据并尝试读取。
This is what the .csv looks like in TextEdit. 这就是.csv在TextEdit中的外观。 Header and the first couple school entries.
标头和第一对情侣入学。
I downloaded the .csv
, saved it as a .xlsx
file, and then used read_excel()
instead, which worked: 我下载了
.csv
,将其保存为.xlsx
文件,然后使用read_excel()
代替了,它可以正常工作:
import pandas as pd
path = "C:\\Users\\nickb\\Desktop\\CCC.xlsx" # update accordingly
df = pd.read_excel(path)
print df.head()
Facility Type Facility Number \
0 DAY CARE CENTER 197416900
1 DAY CARE CENTER 191607790
2 DAY CARE CENTER 197416698
3 DAY CARE CENTER 304370894
4 DAY CARE CENTER 384001195
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.