简体   繁体   English

Python Pandas CParserError错误标记数据

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

相关问题 Pandas CParserError:标记数据时出错 - Pandas CParserError: Error tokenizing data CParserError:错误标记数据 - CParserError: Error tokenizing data 熊猫错误:pandas.io.common.CParserError:标记数据时出错 - Error with pandas: pandas.io.common.CParserError: Error tokenizing data 熊猫加载文本文件错误:CParserError:错误标记数据 - Pandas load text file error: CParserError: Error tokenizing data Python Pandas 错误标记数据 - Python Pandas Error tokenizing data 在 pandas 中读取 csv 文件时出错 [CParserError: 标记数据时出错。 C 错误:捕获缓冲区溢出 - 可能是格式错误的输入文件。] - Error in Reading a csv file in pandas[CParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.] pandas.io.common.CParserError:标记数据时出错。 C错误:捕获了缓冲区溢出-可能是格式错误的输入文件 - pandas.io.common.CParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file Python Pandas 对数据进行标记时出错 - Python Pandas Error while Tokenizing Data CParserError:标记数据时出错。 阅读跨书数据集时 - CParserError: Error tokenizing data. when reading book-crossing dataset Pandas,ParserError:错误标记数据 - Pandas, ParserError: Error tokenizing data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM