PDF Table Extractor CLI
A lightweight CLI utility and Python library to extract structured tables from PDF files directly into clean, editable Microsoft Excel (.xlsx) or .csv files.
An online browser-based version is available at TheFreeConverter PDF to Excel Converter.
Features
- Multi-Table Detection: Automatically detects table boundaries on each page.
- Smart Sheet Naming: Multi-table documents are organized with each table placed onto its own sheet (e.g.
Page1_T1,Page2_T1). - Header Normalization: Strips excessive whitespace, eliminates empty columns, and deduplicates column headers.
- Flexible Formats: Export to multi-sheet
.xlsxworkbooks or individual.csvfiles. - Local Execution: Runs entirely on your local machine with no external network calls.
Installation
pip install pdf-table-extractor-cli
Or install from source:
git clone https://github.com/The-Free-Converter/pdf-table-extractor.git
cd pdf-table-extractor
pip install -r requirements.txt
pip install -e .
Quickstart & CLI Usage
1. Extract tables to an Excel (.xlsx) file
pdf-table-extractor statement.pdf
# Outputs: statement.xlsx with one sheet per detected table
2. Specify a custom output path
pdf-table-extractor invoice.pdf -o ./output/parsed_invoice.xlsx
3. Export tables as separate CSV files
pdf-table-extractor quarterly_report.pdf --csv
# Outputs: quarterly_report_Page1_T1.csv, quarterly_report_Page2_T1.csv, ...
Python API Usage
You can also use pdf-table-extractor as a Python module in your scripts:
from pdf_table_extractor import TableExtractor, extract_tables_to_excel
# Simple one-line conversion
tables_found = extract_tables_to_excel("financial_report.pdf", "output.xlsx")
print(f"Extracted {tables_found} tables into output.xlsx")
# Advanced: Access raw pandas DataFrames
extractor = TableExtractor("financial_report.pdf")
tables = extractor.extract_all_tables()
for table in tables:
page_num = table["page"]
sheet_name = table["sheet_name"]
df = table["data"]
print(f"--- Page {page_num} ({sheet_name}) ---")
print(df.head())
Troubleshooting & Best Practices
- Scanned Documents:
This tool is designed for native digital PDFs with selectable text layers (such as invoices, bank statements, and software exports). Scanned PDFs containing only raster images require an OCR step beforehand. - Merged Headers:
Tables with multi-row merged headers may require manual column verification in Excel. - Large Files:
For very large documents, extract specific pages or use the web version.
Web Version
The web version is hosted at:
https://thefreeconverter.com/converters/document-converters/pdf-to-excel-converter
License
This project is licensed under the MIT License - see the LICENSE file for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_table_extractor_cli-1.0.0.tar.gz.
File metadata
- Download URL: pdf_table_extractor_cli-1.0.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f28ec71677fb5b7e59a6ab0e00c048efce3e833f8e5c17e5981665234e446bc
|
|
| MD5 |
70883674abed9530fcb509700994f974
|
|
| BLAKE2b-256 |
5ace4ba06c139e32f1404a4fdbd3b19042858d9b5f0216d17733dfc579a5b6bd
|
File details
Details for the file pdf_table_extractor_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pdf_table_extractor_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1246a9b22def6e87fc991fd39d89d928fde8c8f63715c13214790c0245a9809
|
|
| MD5 |
7715fe8b67b4d441457ba800f6d174d5
|
|
| BLAKE2b-256 |
db4f7573cc5f0f91325c748a9ba5b5cec937984240179580d7fcea0d0884bac5
|