Add 'src/find-missing-from-docx.py'
This commit is contained in:
parent
14a8a63c14
commit
e0781ade05
23
src/find-missing-from-docx.py
Normal file
23
src/find-missing-from-docx.py
Normal file
@ -0,0 +1,23 @@
|
||||
### EXAMPLE CODE ONLY:::
|
||||
|
||||
from docx import Document
|
||||
|
||||
def extract_table(file_path):
|
||||
document = Document(file_path)
|
||||
print(document.tables)
|
||||
table = document.tables[0]
|
||||
|
||||
data = []
|
||||
keys = None
|
||||
for i, row in enumerate(table.rows):
|
||||
text = (cell.text for cell in row.cells)
|
||||
if i == 0:
|
||||
keys = tuple(text)
|
||||
continue
|
||||
row_data = dict(zip(keys, text))
|
||||
data.append(row_data)
|
||||
|
||||
print(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
extract_table("./file.docx")
|
Reference in New Issue
Block a user