Conversation
…l with the value of the previous cell (e.g. in the case of row/cell merges) fails, because there simply has not been a 'previous cell' yet
|
@aanastasiou there was a recent update that addressed the "skipped-cells" condition that is actually a legitimate (although relatively unusual) table state. If you use Depending on your needs for column alignment you may want to use There is also a new I'm not sure what we'll do with |
|
@scanny thank you very much for the prompt response. This was using the latest |
|
This change appears in v1.1.2, which is the current PyPI version, released on May 1, 2024: |
|
@scanny This is the version that I used (and eventually led me to file this PR) |
|
Show me the client code that isn't working the way you want. |
|
@scanny The PR contains the exact problem that I dealt with (and how), what might take longer is me locating the exact document that causes this behaviour. |
|
@aanastasiou the idea there is not that this problem with If you can post the code you're using to traverse cells and which gives rise to the error you mention I expect I'll be able to describe how to modify it to avoid any exceptions for uneven row lengths. |
I am pre-processing a large number of
.docxdocuments with really oddly shaped tables containing text that has to be extracted verbatim.As useful
python-docxhas been in this task, a subset of those documents revealed a tiny little bug in this line.This PR fixes cases of odd table shapes were the strategy of populating a cell with the value of the previous cell (e.g. in the case of row/cell merges) fails, because there simply has not been a 'previous cell' yet.
Please note, I would be glad to contribute a test case as well but this might take a bit more time, tracking down the exact table (within the XML) that causes the bug and creating an "equivalent" test case.
Hope this helps.