[Python] xlrd assertion error when opening a .xls file (converted from .xlsx): assert...

Discussão em 'Python' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have a script that uses the xlrd library to read and write .xls files. The program works for most .xls', but I found that after I converted an .xlsx to .xls and try to open the workbook, I get the following assertion error:

    Traceback (most recent call last):
    File "/home/troublebucket/Projects/script.py", line 51, in <module>
    wb = xlrd.open_workbook(bom_table_wb)
    File "/home/troublebucket/.local/lib/python3.10/site-packages/xlrd/__init__.py", line 172, in open_workbook
    bk = open_workbook_xls(
    File "/home/troublebucket/.local/lib/python3.10/site-packages/xlrd/book.py", line 104, in open_workbook_xls
    bk.parse_globals()
    File "/home/troublebucket/.local/lib/python3.10/site-packages/xlrd/book.py", line 1211, in parse_globals
    self.handle_sst(data)
    File "/home/troublebucket/.local/lib/python3.10/site-packages/xlrd/book.py", line 1178, in handle_sst
    self._sharedstrings, rt_runlist = unpack_SST_table(strlist, uniquestrings)
    File "/home/troublebucket/.local/lib/python3.10/site-packages/xlrd/book.py", line 1472, in unpack_SST_table
    assert _unused_i == nstrings - 1
    AssertionError


    I tried commenting out the assertion in book.py's unpack_SST_table(), and the script ran without errors but didn't actually read from the workbook. Any advice would be appreciated!

    Continue reading...

Compartilhe esta Página