Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scraping data from PDF to CSV? Python vs PHP?

I have a bunch of reports that I'm hand-compiling every day and it's taking forever, so I was thinking of automating the whole process. I will be scraping data from: (1) HTML, (2) CSV/XLS, (3) PDF. I have mainly only scraped data from CSV/HTML with PHP and was wondering if there are any dependable libraries or ways of grabbing table data from a PDF in PHP?

I have also just started learning Python and see that it might be a good idea to try doing this with PDFMiner in conjunction with Scrapy. Would this be better? Or are there other options?

Please let me know. Thanks!

like image 368
tr3online Avatar asked Sep 09 '11 02:09

tr3online


2 Answers

Beautiful Soup is another good alternative for scraping and PDFminer has been the best PDF parser for Python I have found. I use pdf2txt.py mostly and then re-format from there if needed.

like image 155
Stedy Avatar answered Nov 02 '22 19:11

Stedy


If you have command line access to a linux server try the pdftotext command

$ pdftotext file.pdf

If you're lucky you'll get something that you can work with. Depending on the PDF the text may come out weird from the way the tables were originally formatted, in my experience anyway. Good Luck.

like image 29
Adam Avatar answered Nov 02 '22 21:11

Adam