Найти - Пользователи
Полная версия: read_csv не работает
Начало » Python для новичков » read_csv не работает
1
ShuraP
 import pandas as pd
path = r'C:\Users\apougatc\Desktop\Spectrum\J1OptimResults_Coma_Measruement_051118_Low NA_ObjID_216J011-NG_ObjAng_0.log'
df = pd.read_csv(path, sep=',')


3 строчки и не работаеть.помогите где ошибка
файл во вложении

 runfile('C:/Users/apougatc/.spyder-py3/Ope_Files.py', wdir='C:/Users/apougatc/.spyder-py3')
Traceback (most recent call last):
  File "<ipython-input-11-4d92e8e7a388>", line 1, in <module>
    runfile('C:/Users/apougatc/.spyder-py3/Ope_Files.py', wdir='C:/Users/apougatc/.spyder-py3')
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/Users/apougatc/.spyder-py3/Ope_Files.py", line 4, in <module>
    df = pd.read_csv(path, sep=',')
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 709, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 455, in _read
    data = parser.read(nrows)
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 1069, in read
    ret = self._engine.read(nrows)
  File "C:\Users\apougatc\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 1839, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 902, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 924, in pandas._libs.parsers.TextReader._read_low_memory
  File "pandas/_libs/parsers.pyx", line 978, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 965, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas/_libs/parsers.pyx", line 2208, in pandas._libs.parsers.raise_parser_error
ParserError: Error tokenizing data. C error: Expected 1 fields in line 8, saw 2
passant
Стесняюсь спросить.
А вы вообще-то говоря знаете, что такое csv-файл? А за одно, откуда вы взяли, что ваш log-файл содержит данные в csv-формате?
aydat
У вас файл не пригоден для загрузки, сначала нужно его обработать
ShuraP
спасибо большое понял
ShuraP

сделал так, кому интересно
 out = pd.read_csv(path , sep=';', skiprows=[0], header=None)
                  data_array = pd.DataFrame([out[0][i].split('\t') for i in range(len(out))])
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB