Created
January 18, 2014 05:12
-
-
Save jeremybmerrill/8486499 to your computer and use it in GitHub Desktop.
A snippet to extract spreadsheet data from a PDF using Tabula's tabula-extractor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tabula' | |
pdf_file_path = "czechmaybe.pdf" | |
outfilename = "czechmaybe.csv" | |
out = open(outfilename, 'w') | |
extractor = Tabula::Extraction::ObjectExtractor.new(pdf_file_path, [5] ) #:all ) # 1..2643 | |
extractor.extract.each do |pdf_page| | |
pdf_page.spreadsheets.each do |spreadsheet| | |
out << spreadsheet.to_csv | |
out << "\n\n" | |
end | |
end | |
out.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment