How to read Excel files from a stream (not a disk-backed file) in Python?

后端 未结 4 2245
说谎
说谎 2021-02-19 16:59

XLRD is installed and tested:

>>> import xlrd
>>> workbook = xlrd.open_workbook(\'Sample.xls\')

When I read the file through

4条回答
  •  感动是毒
    2021-02-19 17:26

    xlrd does support providing data directly without a filepath, just use the file_contents argument:

    xlrd.open_workbook(file_contents=fileobj.read())
    

    From the documentation:

    file_contents – A string or an mmap.mmap object or some other behave-alike object. If file_contents is supplied, filename will not be used, except (possibly) in messages.

提交回复
热议问题