A library for converting a HTML tables into ASCII tables, rowspan and colspan allowed!
Project description
DashTable
Video Tutorial
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 --center_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, center_cells=False, center_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
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
dashtable-1.3.8.tar.gz
(9.3 kB
view details)
File details
Details for the file dashtable-1.3.8.tar.gz
.
File metadata
- Download URL: dashtable-1.3.8.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
87cf60c84f51c5cebca941a47fff80292d06743006a9f37cfbbea7ffac7a30f7
|
|
MD5 |
8da29248cab7651cb51aa68b28ca983b
|
|
BLAKE2b-256 |
882279b18c06c937663baa4781d59537a20dd368667236515b7491aab5a0af9f
|