2017-09-25 3 views
0

Wenn ich dieses Skript ausführen, funktioniert es nicht und ich weiß nicht warum. Kannst du mir helfen?Fehler mit Pandas: pandas.io.common.CParserError: Fehler Tokening Daten

import pandas as pd 
data1 = pd.read_csv(url) 
print(data1) 

Fehler:

Traceback (most recent call last): 
    File "C:\Users\abc\Desktop\script.py", line 4, in <module> 
    data1 = pd.read_csv(url) 
    File "C:\Users\abc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f 
    return _read(filepath_or_buffer, kwds) 
    File "C:\Users\abc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 401, in _read 
    data = parser.read() 
    File "C:\Users\abc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 939, in read 
    ret = self._engine.read(nrows) 
    File "C:\Users\abc\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\io\parsers.py", line 1508, in read 
    data = self._reader.read(nrows) 
    File "pandas\parser.pyx", line 848, in pandas.parser.TextReader.read (pandas\parser.c:10415) 
    File "pandas\parser.pyx", line 870, in pandas.parser.TextReader._read_low_memory (pandas\parser.c:10691) 
    File "pandas\parser.pyx", line 924, in pandas.parser.TextReader._read_rows (pandas\parser.c:11437) 
    File "pandas\parser.pyx", line 911, in pandas.parser.TextReader._tokenize_rows (pandas\parser.c:11308) 
    File "pandas\parser.pyx", line 2024, in pandas.parser.raise_parser_error (pandas\parser.c:27037) 
pandas.io.common.CParserError: Error tokenizing data. C error: Expected 45 fields in line 49, saw 46 

Vielen Dank!

+0

Was ist ein Separator? – jezrael

+0

Was ist die URL? Wie sehen die Daten aus? Sie erwarten wirklich, dass andere helfen, wenn so wenig Informationen zur Verfügung gestellt werden? – Yorian

+0

@ Yorian sie sind vertrauliche Daten. Ich kann dir die URL nicht geben. –

Antwort

0

So ist es nicht möglich zu sagen. Ich empfehle, PyCharm zu downloaden, und führen Sie den Code im Debugging-Modus, Schritt für Schritt gehen, um zu sehen, wo das mögliche Problem ist.

Siehe Dokumentation JetBrains.

1

in Pandas Handle, sollten Sie in der Lage der csv übergeben.

Beispiel: pd.read_csv (location.of.archive) Like: pd.read_csv (myfile.csv)

Das ist alles!