Python error "pandas.errors.ParserError: Error tokenizing data"

0 votes

Python Code:

# -*- coding: utf-8 -*-
import pandas as pd

df = pd.read_csv("C:\Users\Kamal\Desktop\Desktop\datasets\ex.xlsx")

for index, row in df.iterrows():
    print (row[1]['emailid'])

Error:

  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
pandas.errors.ParserError: Error tokenizing data. C error: Expected 2 fields in line 11, saw 3
Jun 13 in Python by Kamal
2,065 views

1 answer to this question.

0 votes

Pandas do not take .xlsx files. Rename the file to .csv and it should work and use the .csv file instead of the .xslx

# -*- coding: utf-8 -*-
import pandas as pd

df = pd.read_csv("C:\Users\Kamal\Desktop\Desktop\datasets\ex.csv")

for index, row in df.iterrows():
    print (row[1]['emailid'])
answered Jun 13 by Rhea

Related Questions In Python

0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 57,300 points
2,493 views
–1 vote
1 answer

Python pandas axis error

When you are applying sum() you don't ...READ MORE

answered Jan 8 in Python by Omkar
• 68,480 points
250 views
0 votes
1 answer

Why am I getting a error when I am printing two different data types in python?

different data type is being used. that ...READ MORE

answered Mar 6 in Python by Mohammad
• 3,170 points
51 views
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

answered Aug 19 in Python by Noel Deepak Palle
648 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 417 views
+4 votes
6 answers
0 votes
1 answer

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

There is no attribute called “rows”. The ...READ MORE

answered Mar 28 in Python by Shri
8,858 views
+3 votes
5 answers

How to read multiple data files in python

Firstly we will import pandas to read ...READ MORE

answered Apr 6, 2018 in Python by DeepCoder786
• 1,720 points
3,142 views