Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Python module for converting a html table to a list of dictionaries.

Project Description

table2dicts

Python module for converting a html table to a list of dictionaries.

Installation

TODO

Usage

Give it some html with a table:

>>> table2dicts('''
...    <table>
...         <thead>
...             <tr><th>a</th><th>b</th><th>c</th></tr>
...         </thead>
...         <tbody>
...             <tr><td>1</td><td>2</td><td>3</td></tr>
...             <tr><td>4</td><td>5</td><td>6</td></tr>
...         </tbody>
...    </table>
... ''')
[OrderedDict([('a', '1'), ('b', '2'), ('c', '3')]), OrderedDict([('a', '4'), ('b', '5'), ('c', '6')])]

No thead or tbody, no problem:

>>> table2dicts('''
...    <table>
...        <tr><th>a</th><th>b</th><th>c</th></tr>
...        <tr><td>1</td><td>2</td><td>3</td></tr>
...        <tr><td>4</td><td>5</td><td>6</td></tr>
...    </table>
... ''')
[OrderedDict([('a', '1'), ('b', '2'), ('c', '3')]), OrderedDict([('a', '4'), ('b', '5'), ('c', '6')])]

When no th is present, the first row of td elements is used as a header:

>>> table2dicts('''
...    <table>
...        <tr><td>a</td><td>b</td><td>c</td></tr>
...        <tr><td>1</td><td>2</td><td>3</td></tr>
...        <tr><td>4</td><td>5</td><td>6</td></tr>
...    </table>
... ''')
[OrderedDict([('a', '1'), ('b', '2'), ('c', '3')]), OrderedDict([('a', '4'), ('b', '5'), ('c', '6')])]
Release History

Release History

This version
History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
table2dicts-0.2.tar.gz (2.3 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting