Jun-27-2024, 05:28 AM
(This post was last modified: Jun-27-2024, 05:43 AM by Pedroski55.)
Got an example docx file to work on?
If the files are unreadable, nothing will help!
This gets the tables to pandas:
If the files are unreadable, nothing will help!
This gets the tables to pandas:
from docx import Document import pandas as pd mydocxfile = '/home/pedro/myPython/docxFiles/example_table2.docx' for table in Document(mydocxfile).tables: data = [[cell.text for cell in row.cells] for row in table.rows] print(pd.DataFrame(data[1:], columns=data[0]), "\n")Gives:
Output: Name Age Occupation
0 King Charles 75 King
1 Pedro 55 Layabout
2 Baby 32 Import-Export