Extract tables from PDFs to pandas, polars, and JSON. / Extrae tablas de PDFs a pandas, polars y JSON.
Project description
Tabulex
English | Espanol
English
Tabulex is a Python library for detecting tables in digital PDFs, reconstructing their structure, and exporting them to pandas, polars, and JSON.
Features
- Process one-page or multi-page PDF files.
- Detect tables with
PyMuPDFplus a text-geometry fallback heuristic. - Preserve multiline cells by joining lines with
\n. - Represent merged cells with
rowspanandcolspanin an intermediate model. - Store cell images as base64.
- Export tables as Pandas, Polars, or JSON.
Installation
pip install tabulex
Quick Start
from tabulex import extract_tables
result = extract_tables("sample-tables.pdf", return_type="all")
print(result.pandas_tables[0])
print(result.polars_tables[0])
print(result.json_tables[0])
JSON Output
from tabulex import extract_tables
result = extract_tables("sample-tables.pdf", return_type="json")
print(result.json_tables[0])
Main API
extract_tables(
pdf_path: str,
pages: list[int] | None = None,
return_type: str = "both",
preserve_spans: bool = True,
preserve_images: bool = True,
image_encoding: str = "base64",
engine: str = "pymupdf",
)
extract_tables(...) returns an ExtractionResult with:
tablespandas_tablespolars_tablesjson_tablesmetadata
Limitations
- V1 targets digital PDFs.
- Scanned PDFs and OCR-heavy workflows are not part of the default path.
- Borderless tables still rely on heuristics.
- Tables continued across pages are handled separately.
License
MIT. See LICENSE.
Espanol
Tabulex es una libreria Python para detectar tablas en PDFs digitales, reconstruir su estructura y exportarlas a pandas, polars y JSON.
Caracteristicas
- Procesa PDFs de una o varias paginas.
- Detecta tablas con
PyMuPDFy una heuristica de respaldo basada en geometria del texto. - Conserva celdas multilinea uniendo las lineas con
\n. - Representa celdas fusionadas con
rowspanycolspanen un modelo intermedio. - Almacena imagenes de celdas como base64.
- Exporta tablas a Pandas, Polars o JSON.
Instalacion
pip install tabulex
Uso Rapido
from tabulex import extract_tables
result = extract_tables("sample-tables.pdf", return_type="all")
print(result.pandas_tables[0])
print(result.polars_tables[0])
print(result.json_tables[0])
Salida JSON
from tabulex import extract_tables
result = extract_tables("sample-tables.pdf", return_type="json")
print(result.json_tables[0])
API Principal
extract_tables(
pdf_path: str,
pages: list[int] | None = None,
return_type: str = "both",
preserve_spans: bool = True,
preserve_images: bool = True,
image_encoding: str = "base64",
engine: str = "pymupdf",
)
extract_tables(...) devuelve un ExtractionResult con:
tablespandas_tablespolars_tablesjson_tablesmetadata
Limitaciones
- La V1 esta pensada para PDFs digitales.
- Los PDFs escaneados y los flujos con OCR no forman parte del camino principal.
- Las tablas sin bordes siguen dependiendo de heuristicas.
- Las tablas continuadas entre paginas se procesan por separado.
Licencia
MIT. Consulta LICENSE.
Project details
Release history Release notifications | RSS feed
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 tabulex-0.1.0.tar.gz.
File metadata
- Download URL: tabulex-0.1.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2a3ca4d614059711f5a1c83ee522cf9336b68c07f8f7e03dac4aa302a3119f0
|
|
| MD5 |
c251348ad7ee3f45148d34e6dff7b0f1
|
|
| BLAKE2b-256 |
f87c7f1855636b6c14a30bfc67d2887ab7ce7097161d2266937d89925083a65b
|
File details
Details for the file tabulex-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tabulex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bea3925b31638822340043384b19d77f1da5e49c1a70eb74c7b22350281cf41b
|
|
| MD5 |
24c07fcd756367365de85ac0e0b5bca5
|
|
| BLAKE2b-256 |
6b909e24aeedb3931913dbb34ddb12a50f2bfaf798d331e515e0ce5beab0b060
|