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
csv-to-md -s ";" -a r tests/table.csv
csv-to-md -s ";" -a r tests/table.csv | xclip -selection clipboard
psql -h 127.0.0.1 -U postgres postgres -c "select * from test" --csv | csv-to-md
Library
from markdown_table_generator import generate_markdown, table_from_string_list
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)
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)
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!