【发布时间】:2021-03-05 19:16:06
【问题描述】:
我一直在使用 Google 表格中的一个文件,以 CSV 格式发布,并使用 Pandas 读取它来制作数据框,但今天在这里停止工作,这是错误输出:
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in read(self, nrows)
2155 def read(self, nrows=None): 2156 尝试: -> 2157 数据 = self._reader.read(nrows) 2158 除了 StopIteration: 第2159章
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()
pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error()
ParserError:标记数据时出错。 C 错误:第 6 行中应有 1 个字段,但看到了 2
如果我使用同一张工作表,但直接从 Google Drive 中的 CSV 文件中读取,则没有问题,并且工作正常。
如果我使用:
df= pd.read_csv(url,sep='\t', lineterminator='\r')
读取数据没有错误,但我在尝试读取 df 时得到了这个:
希望与question 类似吗? 提前感谢您的关注!
【问题讨论】:
-
看起来您正试图在 HTML 文件上使用
pd.read_csv。 -
以前它工作得很好,因为 Google 表格可以选择以 CSV 格式发布,直到现在,我得到了错误。
标签: python pandas google-sheets google-colaboratory