熊猫阅读csv - 错误

时间:2016-12-17 19:55:28

标签: python pandas

我在阅读带有pandas的CSV文件时遇到问题(我知道还有其他主题,但我无法解决问题)。我的代码是:

import pandas as pd
f = pd.read_csv('1803Ltem.csv',sep='\t', dtype=object,)

我得到的错误是:

    Traceback (most recent call last):
  File "/username/username/Documents/first.py", line 362, in <module>
    fuck = pd.read_csv('1803Ltem.csv',sep='\t', dtype=object,)
  File "/Users/username/anaconda/lib/python3.5/site-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/Users/username/anaconda/lib/python3.5/site-packages/pandas/io/parsers.py", line 325, in _read
    return parser.read()
  File "/Users/username/anaconda/lib/python3.5/site-packages/pandas/io/parsers.py", line 815, in read
    ret = self._engine.read(nrows)
  File "/Users/username/anaconda/lib/python3.5/site-packages/pandas/io/parsers.py", line 1314, in read
    data = self._reader.read(nrows)
  File "pandas/parser.pyx", line 805, in pandas.parser.TextReader.read (pandas/parser.c:8748)
  File "pandas/parser.pyx", line 827, in pandas.parser.TextReader._read_low_memory (pandas/parser.c:9003)
  File "pandas/parser.pyx", line 881, in pandas.parser.TextReader._read_rows (pandas/parser.c:9731)
  File "pandas/parser.pyx", line 868, in pandas.parser.TextReader._tokenize_rows (pandas/parser.c:9602)
  File "pandas/parser.pyx", line 1865, in pandas.parser.raise_parser_error (pandas/parser.c:23325)
pandas.io.common.CParserError: Error tokenizing data. C error: Expected 4 fields in line 4587, saw 5

我做错了什么?

1 个答案:

答案 0 :(得分:2)

尝试将参数<VirtualHost>添加到read_csv