Bennet Leff
Bennet Leff

Reputation: 374

Reading a header from a .docx (Word) file in Python docx

I'm parsing docx files using the library python-docx. I need to read the header of documents as well as paragraphs however I can't find anything about document headers in their documentation. There is documentation on writing a header to a new file but none on reading a header. Is there a way to do this?

Upvotes: 2

Views: 1190

Answers (1)

Yaron
Yaron

Reputation: 1852

I had the same problem. I used instead of the "python-docx" package a newer version called python-docx2txt (https://github.com/ankushshah89/python-docx2txt) which extract the text with the headers in one line.

Upvotes: 1

Related Questions