Skip to main content

HTML Table Parse

A lightweight HTML table parser that converts tables to Python data structures without pandas.

Installation

pip install html-table-parse

Usage

from html_table_parse import to_list, to_dict, to_dicts

html = """
<table>
    <tr><th>Name</th><th>Age</th><th>City</th></tr>
    <tr><td>Alice</td><td>30</td><td>NYC</td></tr>
    <tr><td>Bob</td><td>25</td><td>LA</td></tr>
</table>
"""

# List of lists
to_list(html)
# [['Name', 'Age', 'City'], ['Alice', '30', 'NYC'], ['Bob', '25', 'LA']]

# Dictionary of columns
to_dict(html)
# {'Name': ['Alice', 'Bob'], 'Age': ['30', '25'], 'City': ['NYC', 'LA']}

# List of dictionaries
to_dicts(html)
# [{'Name': 'Alice', 'Age': '30', 'City': 'NYC'}, 
#  {'Name': 'Bob', 'Age': '25', 'City': 'LA'}]

Features

  • No pandas required - lightweight alternative to pandas.read_html()
  • Supports colspan and rowspan attributes
  • Handles duplicate headers (auto-numbered)
  • Multiple output formats: lists, dict of columns, or list of dicts
  • Automatic whitespace normalization
  • Fast parsing with lxml

API

to_list(html: str, index: int = 0) -> list[list]

Parse table as list of rows.

to_dict(html: str, index: int = 0) -> dict[str, list]

Parse table as dictionary of columns (first row = headers).

to_dicts(html: str, index: int = 0) -> list[dict]

Parse table as list of dictionaries (first row = headers).

Metadata

Release files for html-table-parse 0.2.2

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

Source distribution (sdist)

Source distribution for html-table-parse 0.2.2
File Size Uploaded
html_table_parse-0.2.2.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html-table-parse 0.2.2
File Interpreter ABI Platform
html_table_parse-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / html_table_parse-0.2.2.tar.gz

Download URL html_table_parse-0.2.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4c57fcfc440f54bb476902e14775d06007e06718ea4f04b077bd315cff058ffc
BLAKE2b-256 checksum
How to use checksums
46ff9a6a96081f387e16a6e1f2cd0fb2d546ee11b411ced57f37d371402e4c27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / html_table_parse-0.2.2-py3-none-any.whl

Download URL html_table_parse-0.2.2-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8e202c8f193ed20fba0d49a7f0b526461cc4e4b4cfb46b0372b4d8a915f28f1
BLAKE2b-256 checksum
How to use checksums
79f88be73d481d99f68767fb8e65ffea968992c0712fd033d7a8244281a00d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2

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