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
99 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
• 56,160 points
600 views
0 votes
1 answer

Python pandas axis error

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

answered Jan 8 in Python by Omkar
• 67,120 points
107 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
• 1,500 points
30 views
0 votes
0 answers

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

for i in cnames:     print(i)     df_csv[i] = (df_csv[i] - ...READ MORE

5 days ago in Python by anonymous
9 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 128 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
1,234 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,700 points
1,034 views