Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
communitycreator

What is Camelot?

Mohammad Razi ul Haq

Camelot is a Python library that allows for the easy extraction of data tables from PDFPortable Document Format files. However, this library only works with text-based PDFswhich allow data to be selected through cursor and not with scanned PDFs.

Camelot has multiple settings that can be tweaked for better extraction of data in tables. This offers more control over the extraction process than other available libraries.

Camelot converts data tables in PDFs to dataframes.

Installation

The following command installs Camelot:

pip install "camelot-py[cv]"

Usage

Below is a basic code that reads a table in a PDF and converts it to a CSV and Dataframe:

import camelot
table = camelot.read_pdf('sample.pdf')
print(table)  // Displays the number of tables read from the pdf

table.export('sample_table.csv', f='csv', compress=True) // saves the table to a csv file.

table[0] // displays the table shape

tables[0].df // converts the table to a dataframe.

RELATED TAGS

python
communitycreator

CONTRIBUTOR

Mohammad Razi ul Haq
RELATED COURSES

View all Courses

Keep Exploring