Skip to main content

PDF Table Extractor CLI

PyPI version License: MIT Web Tool

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 .xlsx workbooks or individual .csv files.
  • 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

  1. 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.
  2. Merged Headers:
    Tables with multi-row merged headers may require manual column verification in Excel.
  3. 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.

Metadata

Release files for pdf-table-extractor-cli 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf-table-extractor-cli 1.0.0
File Size Uploaded
pdf_table_extractor_cli-1.0.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf-table-extractor-cli 1.0.0
File Interpreter ABI Platform
pdf_table_extractor_cli-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / pdf_table_extractor_cli-1.0.0.tar.gz

Download URL pdf_table_extractor_cli-1.0.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8f28ec71677fb5b7e59a6ab0e00c048efce3e833f8e5c17e5981665234e446bc
BLAKE2b-256 checksum
How to use checksums
5ace4ba06c139e32f1404a4fdbd3b19042858d9b5f0216d17733dfc579a5b6bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / pdf_table_extractor_cli-1.0.0-py3-none-any.whl

Download URL pdf_table_extractor_cli-1.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1246a9b22def6e87fc991fd39d89d928fde8c8f63715c13214790c0245a9809
BLAKE2b-256 checksum
How to use checksums
db4f7573cc5f0f91325c748a9ba5b5cec937984240179580d7fcea0d0884bac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page