Python Forum

Full Version: [supernoob2] Trying Numpy and THIS happened...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm playing around with numpy trying to get an idea of what it can do, but I get an error and can't figure out what's happening for the sake of me:

PyDev console: starting.
Python 3.7.3 (default, Jun 24 2019, 04:54:02) 
[GCC 9.1.0] on linux
import numpy as np
import pandas as pd
filename = '/home/abc/weatherlib.txt'
df = pd.read_csv(filename)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/abc/PycharmProjects/calculator/venv/lib/python3.7/site-packages/pandas/io/parsers.py", line 685, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/home/abc/PycharmProjects/calculator/venv/lib/python3.7/site-packages/pandas/io/parsers.py", line 463, in _read
    data = parser.read(nrows)
  File "/home/abc/PycharmProjects/calculator/venv/lib/python3.7/site-packages/pandas/io/parsers.py", line 1154, in read
    ret = self._engine.read(nrows)
  File "/home/abc/PycharmProjects/calculator/venv/lib/python3.7/site-packages/pandas/io/parsers.py", line 2048, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 879, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 894, in pandas._libs.parsers.TextReader._read_low_memory
  File "pandas/_libs/parsers.pyx", line 948, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 935, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas/_libs/parsers.pyx", line 2130, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 75, saw 7
what am I doing wrong this time?
It looks like your csv file is messed up, with an inconsistent number of fields (commas) per line. Check out line 75 of the csv file, and compare it to the previous lines.
(Jul-24-2019, 01:16 PM)ichabod801 Wrote: [ -> ]It looks like your csv file is messed up, with an inconsistent number of fields (commas) per line. Check out line 75 of the csv file, and compare it to the previous lines.
thanks!