ich möchte über eine Tabelle in einer Word-Datei iterieren. Das mache ich mit folgendem Code:
Code: Alles auswählen
def getText():
doc = docx.Document('zeug.docx')
table = doc.tables[0]
table_data = {}
for row in table.rows:
translation = row.cells[1].text
table_data[row.cells[0].text] = translation
return table_data
Es funktioniert alles wie gewünscht. Aber für eine Word-Datei mit einer Tabelle mit ca. 1000 Zeilen (und zwei Spalten) dauert das ganze ca. 6 Minuten.
Ich finde das ziemlich langsam. Hat jemand eine Idee, was ich falsch mache oder wie es schneller geht?