dominic tanui
dominic tanui

Reputation: 21

Error in read a .xlsx file using the pandas Library in Python?

I have problem in reading excel file from location.

Error

File "c:\users\dominic\appdata\local\programs\python\python37-32\lib\site-packages\xlrd\__init__.py", line 1187
    print "EXTERNSHEET(b7-):"
                            ^
SyntaxError: invalid syntax

Syntax

import pandas as pd

df = pd.read_excel('DumpData 2.xlsx', sheet_name=None)

Kindly help to resolve the problem above

Upvotes: 1

Views: 3855

Answers (1)

Vijesh
Vijesh

Reputation: 815

You can try below syntax for python-3:

import pandas as pd

df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx', sheet_name='your Excel sheet name')
print (df)

Also, you can try to upgrade the XLRD for python-3

python3 -m pip install --upgrade xlrd

I have Python 3 and Pandas 0.23.4 and it's working fine. Just check your pandas version using print(pd.__version__) and try to upgrade it.

If it doesn't work try to reinstall the pandas & XLRD module using pip

Upvotes: 2

Related Questions