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.
6 comments · 88% upvoted · other discussions
Check Camelot and Tabula
Awqard [OP] 1 points · Feb 2024
Tried both and neither is very reliable unfortunately
skytomorrownow 1 points · Mar 2024
I used Tabula for a project and had to another layer of code to validate and clean up the extracted information. PDF is very information-unfriendly in its internal description (speculative: a leftover from its Postscript origin, and corporate anti-interoperability-seeking).
96_kishan 1 points · Feb 2024
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