Skip to content

Instantly share code, notes, and snippets.

@gilsondev
Created May 16, 2019 02:16
Show Gist options
  • Save gilsondev/f38d3f021d900841427d9e6d8cbaf218 to your computer and use it in GitHub Desktop.
Save gilsondev/f38d3f021d900841427d9e6d8cbaf218 to your computer and use it in GitHub Desktop.
Example to use camelot-py
# Camelot: PDF Table Extraction for Humans
# Documentation: https://camelot-py.readthedocs.io/en/master/
import camelot
# Read the PDF and specify the pages
tables = camelot.read_pdf("manual.pdf", pages='27')
# Visualize with pandas
tables[0].df
# Save the table to CSV
# Compress to zip, and have two files:
# - result_zip-page-27-table-0.csv
# - result_zip-page-27-table-1.csv
tables.export('result_zip.csv', f='csv', compress=True) # json, excel, html
# Other option
tables[0].to_csv('result_file.csv') # to_json, to_excel, to_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment