Python Forum
Problem with importing a CSV file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with importing a CSV file
#1
I have a problem importing a CSV file. I have tried with r' and singel / and dubbel \\ both ways. The same problem.
But I can easily import the same file in R-studio with

"df <- read.csv2(file="G:\\Analyser\\2019 OS\\test.csv",head=TRUE)"

Anybody have a clue what I´m doing wrong? I´m using Anaconda Spyder and I can also import the file directly.


import pandas as pd
pd.read_csv("G:\\Analyser\\2019 OS\\test.csv", header=None)
My error message is:

Traceback (most recent call last):

  File "<ipython-input-2-90f87efa86d2>", line 3, in <module>
    pd.read_csv("G:\\Analyser\\2019 OS\\test.csv", header=None)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 702, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 435, in _read
    data = parser.read(nrows)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1139, in read
    ret = self._engine.read(nrows)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1995, in read
    data = self._reader.read(nrows)
  File "pandas/_libs/parsers.pyx", line 899, in pandas._libs.parsers.TextReader.read
  File "pandas/_libs/parsers.pyx", line 914, in pandas._libs.parsers.TextReader._read_low_memory
  File "pandas/_libs/parsers.pyx", line 968, in pandas._libs.parsers.TextReader._read_rows
  File "pandas/_libs/parsers.pyx", line 955, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas/_libs/parsers.pyx", line 2172, in pandas._libs.parsers.raise_parser_error

ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 2 
Reply


Messages In This Thread
Problem with importing a CSV file - by Chopan2211 - Nov-05-2019, 02:19 PM
RE: Problem with importing a CSV file - by buran - Nov-05-2019, 02:23 PM
RE: Problem with importing a CSV file - by buran - Nov-05-2019, 04:46 PM
RE: Problem with importing a CSV file - by DeaD_EyE - Nov-06-2019, 09:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  New2Python: Help with Importing/Mapping Image Src to Image Code in File CluelessITguy 0 742 Nov-17-2022, 04:46 PM
Last Post: CluelessITguy
  Problem with importing python-telegram library into the project gandonio 1 1,619 Nov-01-2022, 02:19 AM
Last Post: deanhystad
  Problem with importing Python file in Visual Studio Code DXav 7 5,249 Jun-15-2022, 12:54 PM
Last Post: snippsat
  importing functions from a separate python file in a separate directory Scordomaniac 3 1,413 May-17-2022, 07:49 AM
Last Post: Pedroski55
  Importing a function from another file runs the old lines also dedesssse 6 2,618 Jul-06-2021, 07:04 PM
Last Post: deanhystad
  Importing text file into excel spreadsheet with formatting david_dsmn 1 3,660 Apr-05-2021, 10:21 PM
Last Post: david_dsmn
  importing a CSV file into Python russoj5 1 2,985 Aug-02-2020, 12:03 AM
Last Post: scidam
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,216 Jun-29-2020, 08:51 PM
Last Post: buran
  importing CSV file into a OOP Class table using Python faruk61 1 2,996 Apr-15-2020, 12:00 PM
Last Post: faruk61
  importing CSV file into a HTML table using Python trybakov 1 2,320 Feb-22-2020, 09:47 PM
Last Post: scidam

Forum Jump:

User Panel Messages

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