Skip to main content

TableCV

TableCV turns OCR text boxes into a pandas.DataFrame. Use it when you already have OCR output from an image and want a simple table-like result without writing row and column grouping logic yourself.

OCR means optical character recognition: software reads text from an image. Most OCR tools return each piece of text with a bounding box, which is the rectangle around that text. TableCV uses those rectangles to estimate which text belongs in each row and column.

Why Use It

  • Works with any OCR tool that can return text boxes.
  • Returns a familiar pandas.DataFrame.
  • Keeps the core table extraction separate from heavy OCR engines.
  • Supports an optional PaddleOCR path for users who want OCR and table extraction in one call.

Installation

For table extraction from OCR results:

pip install tablecv

For the optional PaddleOCR helper:

pip install "tablecv[paddle]"

On Linux, PaddlePaddle may also need the system OpenMP runtime. For Ubuntu or Debian-based systems, install libgomp1 if importing Paddle fails with a libgomp.so.1 error.

Requirements

  • Python 3.13+
  • pandas and shapely for the core extraction path
  • PaddleOCR only if you call extract_table()

Quick Start With Existing OCR Results

Use extract_table_from_ocr() when your OCR tool has already read the image.

from tablecv import extract_table_from_ocr

ocr_results = [
    ((0, 0, 10, 5), "Name"),
    ((20, 0, 10, 5), "Qty"),
    ((0, 20, 10, 5), "Tea"),
    ((20, 20, 10, 5), "2"),
    ((0, 40, 10, 5), "Coffee"),
    ((20, 40, 10, 5), "1"),
]

df = extract_table_from_ocr(ocr_results)
print(df)

The OCR result format is:

((x, y, width, height), text)

Here, x and y are the top-left position of the text box. width and height are the size of that box.

Quick Start With PaddleOCR

Install the optional extra first:

pip install "tablecv[paddle]"

Then call extract_table() with an image path:

from tablecv import extract_table

df = extract_table("invoice.png")
print(df)

extract_table() initializes PaddleOCR lazily. Importing tablecv does not download OCR models or require PaddleOCR unless you call this function.

How It Works

TableCV estimates a table in four broad steps:

  1. It groups OCR boxes that share similar vertical positions into rows.
  2. It finds the strongest table-like region, ignoring surrounding document text such as invoice headers, addresses, and footers.
  3. It chooses a reference row from repeated column patterns or the table header.
  4. It maps each OCR box in the table region to the closest column.

This works best for documents where the table text boxes line up in repeated rows and columns. For example, it can extract a line-item table from an invoice page that also contains logos, billing details, totals, and footer text.

Limitations

TableCV is a lightweight table estimator, not a full document understanding system.

  • It does not detect table borders or merged cells.
  • It returns the strongest table-like region, not every table on a page.
  • It expects OCR boxes to be close to reading order and reasonably aligned.
  • Skewed, rotated, handwritten, or heavily nested tables may need preprocessing.
  • Real OCR accuracy depends on the OCR engine, image quality, language, and font.

Troubleshooting

libgomp.so.1 Missing

PaddlePaddle depends on an OpenMP runtime on Linux. If extract_table() fails while importing Paddle with libgomp.so.1: cannot open shared object file, install the system package:

sudo apt-get update
sudo apt-get install libgomp1

You do not need PaddleOCR or libgomp1 for extract_table_from_ocr().

Development

This project uses uv, Ruff, pytest, Bandit, and PyPI Trusted Publishing.

make sync
make test
make coverage
make check-commit
make build

Default tests use synthetic OCR boxes and do not download OCR models. Tests that require PaddleOCR, image files, model downloads, or external binaries should be marked as integration.

Publishing

Pushes to main run the package quality gate and publish to PyPI with Trusted Publishing. Before this works, configure PyPI to trust:

  • owner: inquilabee
  • repository: TableCV
  • workflow: .github/workflows/python-publish.yml
  • environment: pypi

Download files

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

Source Distribution

tablecv-0.2.2.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

tablecv-0.2.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file tablecv-0.2.2.tar.gz.

File metadata

  • Download URL: tablecv-0.2.2.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tablecv-0.2.2.tar.gz
Algorithm Hash digest
SHA256 18cf3cdcfef3ac2c3906e2683650cd593efded9b3530d497604c4d3f44d97394
MD5 a5702ecc2c5db8cb7b678b6106a857eb
BLAKE2b-256 e1faf994c5c7a1615d0d49eb8391a9789f78822285d21d3da3fa2d85547b5c10

See more details on using hashes here.

File details

Details for the file tablecv-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tablecv-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tablecv-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6cc0bb598d9cdc1d176c6cccff02df20612d64a01c6c89f8ebe9ea9327ddd0d6
MD5 683671b660d2dec0233df4df906199a0
BLAKE2b-256 8748c0b021c434e4b0f27e6d5bfbba0f901fd98014d2b5042adf0a483a4e2e45

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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