Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when reading strange table #531

Closed
RolandColored opened this issue Aug 3, 2018 · 1 comment · Fixed by BlackBoiler/python-docx#23
Closed

Exception when reading strange table #531

RolandColored opened this issue Aug 3, 2018 · 1 comment · Fixed by BlackBoiler/python-docx#23
Labels

Comments

@RolandColored
Copy link

Hey there,

we stumbled upon a strange docx file in production.

broken_table.docx

When trying to read all cells in this table, an exception is thrown:

from docx import Document

with open('broken_table.docx', 'rb') as fh:
    document = Document(fh)
    print([cell.text for cell in document.tables[0].rows[0].cells])
Traceback (most recent call last):
  File "./broken_table.py", line 5, in <module>
    print([cell.text for cell in document.tables[0].rows[0].cells])
  File "./venv/lib/python3.6/site-packages/docx/table.py", line 384, in cells
    return tuple(self.table.row_cells(self._index))
  File "./venv/lib/python3.6/site-packages/docx/table.py", line 106, in row_cells
    return self._cells[start:end]
  File "./venv/lib/python3.6/site-packages/docx/table.py", line 173, in _cells
    cells.append(cells[-col_count])
IndexError: list index out of range

We are using version 0.8.6 with Python 3.6 and the error occurs on Linux and macOS.

@scanny
Copy link
Contributor

scanny commented Apr 29, 2024

Fixed in v1.1.1 circa Apr 30, 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants