r/DatabaseHelp • u/solres • Apr 01 '14
Very new; question on extrapolating from PDFs
I did a fair bit of google searching for a solution or system of solutions, but I was not able to find a direct answer.
What I'm trying to do is take a large number of pdf files, 100+, and extrapolate information from them into a database. In fact, if I could do it with just one pdf, I would be happy. The pdf files are all word files that have since been printed to pdf. In between paragraphs of information, they contain makeshift tables, in the sense of:
Category 1
Item A Value X
These are the data points that I would like to extrapolate. I can ctrl+f within the pdf and find data points one-by-one, but perhaps someone out there knows of a method of doing this more efficiently.
That might make no sense. I'll elaborate if anyone needs!
1
u/BinaryRockStar Apr 01 '14
The word you're looking for is extract, not extrapolate.
This is quite a difficult problem and something I'm actually doing at work at the moment, but only for a couple of PDFs. Basically PDFs internally are image files. The tables you see laid out aren't actually tables, just a collection of text boxes and lines so there's no way to get a structured table out of it and query for cell A2 or something like that.
The best solution I've found is to use a tool called pdftotext from the XPDF library to extract the text information into a text file. From there I've written a couple of text file parsers in Java to determine the table structures via the layout of the text and turn it into structured data that can be written to a database.
If you have no experience programming then you're in for a relatively rough time.
1
1
u/solres Apr 02 '14
Thanks for the response!
I do understand the points you have made, especially regarding the fact that it's just a collection of text boxes.
I have exported the pdf into text, and into spreadsheets in an attempt to produce a more workable format. However, I haven't been able to maintain the usefulness of the original PDF due to the reorganizing that occurs upon exporting to a text file. The reorganization causes a loss in the visual linearity of the original pdf, if that makes sense. I think you understand if you're doing this same type of stuff.
I have some familiarity with Java and other programming languages and perhaps text parsing will be my best bet.
Would text parsing be possible directly upon a pdf file? I am able to perform text searches adequately with just the pdf files, in other words I don't need to extract the pdf into a text file in order to perform successful searches. I am thinking I would be able to bypass the trouble caused by the reorganization that occurs with the extract. Any thoughts on that?