0
votes

Right now I'm able to read tables and headers separately. Is there a way possible to read table along with it's corresponding header using Python in a word document. Now, I'm using python-docx for reading tables and headers.

Please see the image below for more information about table structure and header. I am not able to read the table header [Table Header & Sub Header] along with the table.

Example table structure

1
It's unclear, what do you want. Where are these tables? How do you read headers and tables separately so far? - gukoff
Added the table image. - Radha

1 Answers

0
votes

It's not stated in your question, but I'm supposing your problem is how to iterate over both paragraphs and tables in a document, in the order they appear (document order).

This problem and some solutions is discussed in this GitHub issue:
https://github.com/python-openxml/python-docx/issues/40

and this one:
https://github.com/python-openxml/python-docx/issues/276

It also appears in this other StackOverflow question:
Retrieve document content with document structure with python-docx