Skip to main content

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

Project description

https://img.shields.io/badge/Donate-PayPal-green.svg

DashTable

Video Tutorial

http://i.imgur.com/v1rGCHn.png

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))

Command Line Method:

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

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))

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))

Project details


Download files

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

Source Distribution

dashtable-1.3.2.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file dashtable-1.3.2.tar.gz.

File metadata

  • Download URL: dashtable-1.3.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dashtable-1.3.2.tar.gz
Algorithm Hash digest
SHA256 8e6d93c3d7e5a0e5123a1f270f8fa01ca6b25624b3ddde46e278df41ef26a5e1
MD5 744f26d39bddfa653063c70895f34cbe
BLAKE2b-256 e7ea54f11187a11d5d80d094b98259c531942d57924df4cf1d68ba211ab8fbe1

See more details on using hashes here.

Supported by

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