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, 2019 in Python by Kamal
18,717 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'])


Hope it helps!!

If you need to know more about Python, It's recommended to join Python course today.

Thanks!

answered Jun 13, 2019 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
• 58,090 points
11,180 views
–1 vote
1 answer

Python pandas axis error

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

answered Jan 8, 2019 in Python by Omkar
• 69,210 points
1,854 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, 2019 in Python by Mohammad
• 3,230 points
790 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 20, 2019 in Python by Noel Deepak Palle
5,519 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,058 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,477 views
0 votes
2 answers

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

Try this: data=pd.read_csv('/your file name', delim_whitespace=Tru ...READ MORE

answered Dec 10, 2020 in Python by anonymous
• 82,880 points
130,292 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
14,787 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP