Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A library for converting a HTML tables into ASCII tables, rowspan and colspan allowed!

Project Description

DashTable

Introduction

Use DashTable to create ASCII tables like this reStructured Table:

+------------+------------+------------+
| Header 1   | Header 2   | Header 3   |
+============+============+============+
| body row 1 | column 2   | column 3   |
+------------+------------+------------+
| body row 2 | Cells may span columns. |
+------------+------------+------------+
| body row 3 | Cells may  | - Cells    |
+------------+ span rows. | - contain  |
| body row 4 |            | - blocks.  |
+------------+------------+------------+

Installation

pip install dashtable

Example Usage

HTML to reStructured Table

html2rst requires a filepath or a string to work.

from dashtable import html2rst

filepath = "path/to/html/file.html"
print(html2rst(filepath, force_headers=False, center_cells=False))

Command Line Method:

python html2rst.py input.html output.rst --force_headers --center_cells

HTML to MarkDown Table

html2md requires a filepath or a string to work.

from dashtable import html2md

filepath = "path/to/html/file.html"
print(html2md(filepath))

Command line method:

python html2md.py input.html output.md

List of Lists to reStructered Table

from dashtable import data2rst

table = [
    ['Row\nSpan', 'Header'],
    ['Cell', ''],
    ['Column Span', '']
    ]

column_span = ([0, 0], [1, 0])
row_span = ([2, 0], [2, 1])

my_spans = [column_span, row_span]

print(data2rst(table, spans=my_spans, use_headers=True, center_cells=False))

List of Lists to Markdown Table

from dashtable import data2md

table = [
    ['Header 1', 'Header 2', 'Header 3'],
    ['Column 1', 'Column 2', 'Column 3']
]

print(data2md(table))
Release History

Release History

This version
History Node

1.3.4

History Node

1.3.3

History Node

1.3.2

History Node

1.3.1

History Node

1.3.0

History Node

1.2.9

History Node

1.2.8

History Node

1.2.7

History Node

1.2.6

History Node

1.2.5

History Node

1.2.4

History Node

1.2.3

History Node

1.2.2

History Node

1.2.1

History Node

1.2.0

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
dashtable-1.3.4.tar.gz (9.1 kB) Copy SHA256 Checksum SHA256 Source Aug 3, 2017

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