py-markdown-table-generator
Python library to generate Markdown table.
Usage
pip3 install markdown_table_generator
CLI
csv-to-md -s ";" -a c tests/table.csv
# | OS | Creator | Company |
# |:-------:|:-----------------:|:---------:|
# | Ubuntu | Mark Shuttleworth | Canonical |
# | FreeBSD | | |
# | Fedora | | Red Hat |
csv-to-md -s ";" -a r tests/table.csv
# | OS | Creator | Company |
# |--------:|------------------:|----------:|
# | Ubuntu | Mark Shuttleworth | Canonical |
# | FreeBSD | | |
# | Fedora | | Red Hat |
csv-to-md -s ";" -a r tests/table.csv | xclip -selection clipboard # Copy markdown table in clipboard
psql -h 127.0.0.1 -U postgres postgres -c "select * from test" --csv | csv-to-md # Generate markdown table from PostgreSQL query
Library
from markdown_table_generator import generate_markdown, table_from_string_list
# ====================================================
# Generate markdown table from list of list of strings
# ====================================================
rows = [
["OS", "Creator", "Company"],
["Ubuntu", "Mark Shuttleworth", "Canonical"],
["FreeBSD", None, None],
["Fedora", None, "Red Hat"],
]
table = table_from_string_list(rows, Alignment.CENTER)
markdown = generate_markdown(table)
print(markdown)
# | OS | Creator | Company |
# |:-------:|:-----------------:|:---------:|
# | Ubuntu | Mark Shuttleworth | Canonical |
# | FreeBSD | | |
# | Fedora | | Red Hat |
# ====================================================
# Generate markdown table from CSV
# ====================================================
csv = """
OS;Creator;Company
Ubuntu;Mark Shuttleworth;Canonical
FreeBSD;;
Fedora;;Red Hat
"""
table = table_from_csv(csv.splitlines(), ";", Alignment.RIGHT)
markdown = generate_markdown(table)
print(markdown)
# | OS | Creator | Company |
# |--------:|------------------:|----------:|
# | Ubuntu | Mark Shuttleworth | Canonical |
# | FreeBSD | | |
# | Fedora | | Red Hat |
Build
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
python3 -m build
Test
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
pytest
Contribute
ln -s "$(pwd)/sh/pre-commit.sh" .git/hooks/pre-commit
... and let's code!
Metadata
Release files for markdown-table-generator 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| markdown_table_generator-1.1.0.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markdown_table_generator-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / markdown_table_generator-1.1.0.tar.gz
| Download URL | markdown_table_generator-1.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e85db805fc5db6bc0b31931460de55e28feefcfee59dfd54bfadfee9c5b905f5
|
|
BLAKE2b-256 checksum How to use checksums |
766b38b68061d8590cfc8ea6b296ece9832193beef7224a4292231734d39e2a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
|
Release files / markdown_table_generator-1.1.0-py3-none-any.whl
| Download URL | markdown_table_generator-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a14af5c81f5bf0c054c4ddd07cf1692a930dd5db33803a83b5d73f877be37e5
|
|
BLAKE2b-256 checksum How to use checksums |
77e377e6e6f763cbca9a2f36410735c025cb76a3cba3b2372a0eeabbf4b72daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
|