I have been unable to solve this problem for four days now. I need to find a cell by a keyword and display information from the adjacent cell. I only need to display a number. How can I do this? image of my file for searching
Here I have to insert the table, row and line numbers manually. But I want to automate this.
How can I automate the search for a page, row and column by keyword?
import re
from docx import Document
document = Document('889411.docx')
table_apartments = document.tables[37] #<--- The page number needs to be automatically substituted
cell_apartments = table_apartments.cell(10, 2) #<---- I need to automatically insert the row and column
num_of_apartments = re.findall("d+", cell_apartments.text)[0]#<---Here I remove the text leaving the numbers
print(num_of_apartments)
New contributor
Grom ila is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1