ron_g
ron_g

Reputation: 1653

pyexcel suddenly no longer opens .xlsx (or .xls)

I have all the necessary dependencies installed:

pyexcel==0.7.0
pyexcel-ezodf==0.3.4
pyexcel-io==0.6.6
pyexcel-ods3==0.6.1
pyexcel-xls==0.7.0

(and some others, which I've omitted). Last week, my code was working. Now I am unable to open the very same .xls

>>> p = Path("data/jr1305221.xls")
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
    book_stream = sources.get_book_stream(**keywords)
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
    a_source = SOURCE.get_book_source(**keywords)
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
    return self.get_a_plugin(
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
    source_cls = self.load_me_now(
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
    if source.is_my_business(action, **keywords):
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
    raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>

or .xlsx

>>> p = Path('data/dummy.xlsx')
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
    book_stream = sources.get_book_stream(**keywords)
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
    a_source = SOURCE.get_book_source(**keywords)
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
    return self.get_a_plugin(
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
    source_cls = self.load_me_now(
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
    if source.is_my_business(action, **keywords):
  File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
    raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>

Even in my docker container, it's stopped working.

As an alternative, I have also tried

with open('data/dummy.xlsx', 'r') as f:
    pyexcel.get_book(file_name=f)

and get the same error.

I have read the docs again. I have rolled back my code to last week. What have I done to deserve this? Why has god forsaken me?

Upvotes: 0

Views: 199

Answers (1)

ron_g
ron_g

Reputation: 1653

file_name needs to be a string, where I was passing in a pathlib.PosixPath

i.e., this returns the error:

p = Path('my_file')
pyexcel.get_book(file_name=p)

this works:

pyexcel.get_book(file_name='my_file')

You can use pyexcel.get_book(file_name=my_file.as_posix()) to get the string representation from the PosixPath.

Upvotes: 0

Related Questions