1

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

6
  • Are you using Python 2? Commented Mar 13, 2020 at 5:23
  • I am using Python 3 Commented Mar 13, 2020 at 5:25
  • The print statement is replaced with the print function in Python3, this looks to be causing the issue. Commented Mar 13, 2020 at 5:26
  • @KeelanPool how do i go about it? Commented Mar 13, 2020 at 5:40
  • Show a minimal example of your code. Commented Mar 13, 2020 at 5:48

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

5 Comments

i have upgraded the ``` XLRD``` but still not working
Could you tell me you pandas version: you can get it using, print(pd.__version__) - @dominictanui
the pandas version is 0.25.3
I have reinstall all, but invain
Upgrading XLRD fixed the error, only for it to be replaced by another error : XLRDError: Excel xlsx file; not supported… Which can be fixed by specifying another engine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.