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'])


  File "pandas\_libs\parsers.pyx", line 899, in
  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

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, 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
• 57,700 points
–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,030 points
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,210 points
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, 2019 in Python by Noel Deepak Palle
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,454 views
0 votes
0 answers
+4 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,800 points
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, 2019 in Python by Shri
+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