5

I do the following:

from docx import Document
document = Document('text.docx')
document.paragraphs[42].text

And it gives me '' whatever number I enter, and for loop to find and replace a word does not work. But if I save the document with document.save('text2.docx'), the document is not empty.
The document is relatively big and contains many different formatting, images, tables, styles.
My task is to find and replace a word in docx document with some correction of the following word, so I will be glad, if you suggest another tool

Alexander Ivanov
  • 195
  • 2
  • 10

1 Answers1

0

I ran into this problem and was able to read the document using docx2txt: https://pypi.org/project/docx2txt/

Nick Koprowicz
  • 153
  • 2
  • 11