From e0781ade05124eae1e330f5638a5ad8a98aa9759 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Fri, 16 Feb 2024 14:08:59 +0000 Subject: [PATCH] Add 'src/find-missing-from-docx.py' --- src/find-missing-from-docx.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/find-missing-from-docx.py diff --git a/src/find-missing-from-docx.py b/src/find-missing-from-docx.py new file mode 100644 index 0000000..20ed307 --- /dev/null +++ b/src/find-missing-from-docx.py @@ -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") \ No newline at end of file