Read line from document

I have a docx file with a text of project and I need to find there a theme of it to use it in my programm. I tried to open and read from the docx directly and converted the file into txt, but it seems like there no opportunity to read lines, only the whole text.
The line I need is not the first line in the file and I know it starts with “Theme:”
How could I find and save the line?

Using Python3
Thanks!

Two options come to mind:

  1. Use a python module that reads docx format and search for the appropriate string with re.search() or similar.
  2. Convert the file to text however and then use re.search() to find the string.

If you need them, the python specifics on opening a file for reading and either reading it line by line or as a string/blob are just a google away.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.