python - csv输入错误

时间:2016-12-12 16:25:52

标签: python python-2.7 csv parsing

我尝试使用pandas导入csv文件。 csv已上传到dropbox,您可以访问:

import pandas as pd
csv_path = "https://www.dropbox.com/s/hulf1rqntmwepql/training_3.csv?dl=0"
data = pd.read_csv(csv_path, sep=',')

并收到以下错误消息:

CParserErrorTraceback (most recent call last)
<ipython-input-44-bf00f19b4b83> in <module>()
      1 csv_path = "https://www.dropbox.com/s/hulf1rqntmwepql/training_3.csv?dl=0"
----> 2 data = pd.read_csv(csv_path, sep=',')

pandas/parser.pyx in pandas.parser.TextReader.read (pandas/parser.c:7988)()

pandas/parser.pyx in pandas.parser.TextReader._read_low_memory (pandas/parser.c:8244)()

pandas/parser.pyx in pandas.parser.TextReader._read_rows (pandas/parser.c:8970)()

pandas/parser.pyx in pandas.parser.TextReader._tokenize_rows (pandas/parser.c:8838)()

pandas/parser.pyx in pandas.parser.raise_parser_error (pandas/parser.c:22649)()

CParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 3

1 个答案:

答案 0 :(得分:1)

DropBox使用dl=标志告诉它是否应该自动触发下载,或者是否应该显示提示用户下载的UI。

现在您收到了下载提示,请尝试使用https://www.dropbox.com/s/hulf1rqntmwepql/training_3.csv?dl=1