PydPiper / pylightxl

A light weight, zero dependency, minimal functionality excel read/writer python library
https://pylightxl.readthedocs.io
MIT License
302 stars 47 forks source link

Load excel from file-like object #57

Closed JhonySousa closed 3 years ago

JhonySousa commented 3 years ago

Pylightxl Version:1.57 Python Version:3.9.7

Summary of Bug/Feature: I receive the data from an HTTP request, convert to an file-like obj using io.BytesIO() and it dosen't load the excel.... Using the openpyxl works, and if I write the data received from the HTTP request in to an file and pass the path to the pylightxl.readxl works... sorry for my English (Using Google Translate)

Traceback:

  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/jhony/Documentos/Programação/Python/Projects/PySimpleGui/ConfiaSatSystem/confiasatsystem/handler/simcard/simABC.py", line 49, in run
    await self.run_main()
  File "/home/jhony/Documentos/Programação/Python/Projects/PySimpleGui/ConfiaSatSystem/confiasatsystem/handler/simcard/alllcom.py", line 101, in run_main
    excel = pylightxl.readxl(file_like_obj)
  File "/home/jhony/Documentos/Programação/Python/Projects/PySimpleGui/ConfiaSatSystem/env/lib/python3.9/site-packages/pylightxl/pylightxl.py", line 115, in readxl
    fn = readxl_check_excelfile(fn)
  File "/home/jhony/Documentos/Programação/Python/Projects/PySimpleGui/ConfiaSatSystem/env/lib/python3.9/site-packages/pylightxl/pylightxl.py", line 189, in readxl_check_excelfile
    raise UserWarning('pylightxl - Incorrect file entry ({}).'.format(fn))
UserWarning: pylightxl - Incorrect file entry (<_io.BytesIO object at 0x7f0e2c94c8b0>).

Suggestion for fix:

PydPiper commented 3 years ago

Hi @JhonySousa thank you for considering using pylightxl. I will take a look at this issue this week and get back to you. It sounds like a straight fileIO object doesnt work for you with pylightxl. I will try to replicate the issue locally and see what we can do.

PydPiper commented 3 years ago

Hi @JhonySousa please upgrade pylightxl to v1.58. The new version should have your fix. Please let us know if you have any more questions. Thank you for using pylightxl!