Detect and convert table image to html table
Project description
Table2HTML
A Python package that converts table images into HTML format using Object Detection model and OCR.
Installation
pip install table2html
Usage
Initialize
from table2html import Table2HTML
table2html = Table2HTML()
Table Detection
detection_data = table2html.TableDetect(image)
# Output: [{"table_bbox": Tuple[int]}]
# Visualize table detection (first table)
from table2html.source import visualize_boxes
cv2.imwrite(
"table_detection.jpg",
visualize_boxes(
image,
[detection_data[0]["table_bbox"]],
color=(0, 0, 255),
thickness=1
)
)
Table detection result:
Structure Detection
data = table2html.StructureDetect(image)
# Output: {
# "cells": List[Dict],
# "num_rows": int,
# "num_cols": int,
# "html": str
# }
# Visualize structure detection
from table2html.source import visualize_boxes
cv2.imwrite(
"structure_detection.jpg",
visualize_boxes(
image,
[cell['box'] for cell in data['cells']],
color=(0, 255, 0),
thickness=1
)
)
# Write HTML output
with open('table.html', 'w') as f:
f.write(data["html"])
Structure detection result:
HTML output: extracted html.
Full Pipeline
Note: The cell coordinates are relative to the cropped table image.
data = table2html(image)
# Output: [{
# "table_bbox": Tuple[int],
# "cells": List[Dict],
# "num_rows": int,
# "num_cols": int,
# "html": str
# }]
Input
image: numpy.ndarray (OpenCV/cv2 image format)
Outputs
A list of extracted tables in structured:
table_bbox: Tuple[int] - Bounding box coordinates (x1, y1, x2, y2) of the tablecells: List[Dict] - List of cell dictionaries, where each dictionary contains:row: int - Row indexcolumn: int - Column indexbox: Tuple[int] - Bounding box coordinates (x1, y1, x2, y2)text: str - Cell text content
num_rows: int - Number of rows in the tablenum_cols: int - Number of columns in the tablehtml: str - HTML representation of the table
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
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 table2html-1.3.0.tar.gz.
File metadata
- Download URL: table2html-1.3.0.tar.gz
- Upload date:
- Size: 80.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a456e98ce0fb2193a8ec4fe12b8ac77e6beaeb4b1530edffcf620f0de565bbf5
|
|
| MD5 |
6d4400efb1d23e7ea310259d6790f542
|
|
| BLAKE2b-256 |
924c1938a18e8f92abedb72ddd3480ae65e11a7778b5723038d8198a93f001f0
|
Provenance
The following attestation bundles were made for table2html-1.3.0.tar.gz:
Publisher:
workflow.yml on jayllfpt/table2html
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
table2html-1.3.0.tar.gz -
Subject digest:
a456e98ce0fb2193a8ec4fe12b8ac77e6beaeb4b1530edffcf620f0de565bbf5 - Sigstore transparency entry: 151264312
- Sigstore integration time:
-
Permalink:
jayllfpt/table2html@4a6088064c1ff0b4ebe52a6691252b0d25d12fac -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/jayllfpt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@4a6088064c1ff0b4ebe52a6691252b0d25d12fac -
Trigger Event:
push
-
Statement type:
File details
Details for the file table2html-1.3.0-py3-none-any.whl.
File metadata
- Download URL: table2html-1.3.0-py3-none-any.whl
- Upload date:
- Size: 80.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08eebe17a526bddfcba2499d510151fb3a290faeeb25396f16fd7b5529d7ccc8
|
|
| MD5 |
393b9d5d93b2017722e01429bea362b6
|
|
| BLAKE2b-256 |
f9446814759f1cb587c24e0087d8061b8b8611642b5def2a96b9d9427f763063
|
Provenance
The following attestation bundles were made for table2html-1.3.0-py3-none-any.whl:
Publisher:
workflow.yml on jayllfpt/table2html
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
table2html-1.3.0-py3-none-any.whl -
Subject digest:
08eebe17a526bddfcba2499d510151fb3a290faeeb25396f16fd7b5529d7ccc8 - Sigstore transparency entry: 151264313
- Sigstore integration time:
-
Permalink:
jayllfpt/table2html@4a6088064c1ff0b4ebe52a6691252b0d25d12fac -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/jayllfpt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@4a6088064c1ff0b4ebe52a6691252b0d25d12fac -
Trigger Event:
push
-
Statement type: