r/pythoncoding • u/Awqard • Feb 09 '24
Extracting structured tables from PDF
As title says, I am working on a task to extract the contents of tables from a PDF. I am able to extract all of the text from the PDF using Fitz, which includes the headers and data from the table. The issue arises when I try to build some logic or pipeline to extract the table data from the text as there is no semantics or metadata denoting the difference between text & table.
Has anyone encountered this task before?
Things i’ve tried: OCR - Tabletransformer GPT4 - Actually performed quite well but not 100% reliable Rules based logic - pdfs reference tables differently or not at all.
Edit: SOLVED, tried 4/5 packages and found pdfplumber to be the best at extracting the table in a structured format. The flexibility of the extraction function is very useful too.
View all comments
Show parent comment
1
u/96_kishan Feb 11 '24
These are most widely used for table extraction. You can look into some hugging face model for it. Let me know if you find any reliable ones