Open
Description
For cells with a field code or a drop down menu, the library does not recognise the text within them.
For example, here is a word table with the first row having dropdown menus, second row having field values and third row just having normal text
Running through the code below
from docx import Document
import pandas as pd
doc = Document("C:\Developer\example\exampletable.docx")
tables = []
for table in doc.tables:
# initialise df
df = [['' for _ in range(len(table.columns))] for _ in range(len(table.rows))]
# populate the df with data from table
for i, row in enumerate(table.rows):
for j, cell in enumerate(row.cells):
df[i][j] = cell.text
tables.append(pd.DataFrame(df))
print(tables[0])
results in this table
0 1
0 Dropdown
1 Field value
2 Normal Text Hello
Here is the files for the above example: example.zip
Metadata
Metadata
Assignees
Labels
No labels