Search code examples
python-3.xpyexcel

Unable to open Excel file using Pyexcel


I want to open a simple excel file using PyExcel and here is my code

>>import  os
>>import pyexcel as pe

>>print('Directory Path=', os.getcwd())
   Directory Path= C:\Users\Contacts\My experimentation
>>sheet = pe.get_sheet(file_name="C:/Users/Contacts/My experimentation/Mylist.xlsx")

enter image description here

This is the name of my Excel file. And this is the error I am getting

Directory Path= C:\Users\Contacts\My experimentation

  Traceback (most recent call last):
  File "C:/Users/Contacts/My experimentation/abc.py", line 5, in <module>
    sheet = pe.get_sheet(file_name="C:/Users/Contacts/My experimentation/Mylist.xlsx")
  File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\pyexcel\core.py", line 36, in get_sheet
    named_content = sources.get_sheet_stream(**keywords)
  File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\pyexcel\internal\core.py", line 20, in get_sheet_stream
    sheets = a_source.get_data()

Can anyone tell me what I am doing wrong? Thank you!


Solution

  • The solution might be installing this plugin to support the XLS file format:

    pip install pyexcel-xls
    

    for XLSX, then pip install pyexcel-xlsx. Just go to your scripts folder and open command window there and write down the command. Hope this helps.