Python Forum
[supernoob2] Trying Numpy and THIS happened...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[supernoob2] Trying Numpy and THIS happened...
#1
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?
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(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!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020