Skip to main content

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 PyMuPDF plus a text-geometry fallback heuristic.
  • Preserve multiline cells by joining lines with \n.
  • Represent merged cells with rowspan and colspan in 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:

  • tables
  • pandas_tables
  • polars_tables
  • json_tables
  • metadata

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 PyMuPDF y una heuristica de respaldo basada en geometria del texto.
  • Conserva celdas multilinea uniendo las lineas con \n.
  • Representa celdas fusionadas con rowspan y colspan en 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:

  • tables
  • pandas_tables
  • polars_tables
  • json_tables
  • metadata

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tabulex-0.1.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tabulex-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

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

Hashes for tabulex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b2a3ca4d614059711f5a1c83ee522cf9336b68c07f8f7e03dac4aa302a3119f0
MD5 c251348ad7ee3f45148d34e6dff7b0f1
BLAKE2b-256 f87c7f1855636b6c14a30bfc67d2887ab7ce7097161d2266937d89925083a65b

See more details on using hashes here.

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

Hashes for tabulex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bea3925b31638822340043384b19d77f1da5e49c1a70eb74c7b22350281cf41b
MD5 24c07fcd756367365de85ac0e0b5bca5
BLAKE2b-256 6b909e24aeedb3931913dbb34ddb12a50f2bfaf798d331e515e0ce5beab0b060

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page