Markdown Table Generator
py-markdown-table is an active Python library, currently at version 1.3.0, designed to generate formatted markdown tables from a list of dictionaries. It boasts zero dependencies and releases updates periodically, addressing bug fixes and enhancing formatting options.
Warnings
- breaking The import namespace changed from `markdownTable` to `py_markdown_table.markdown_table` in v1.0.0. Older versions (<1.0.0, e.g., v0.4.0) provided a warning about this impending change.
- breaking Deprecated methods were removed in v1.0.0 as part of a code cleanup and simplification.
- gotcha The library expects input data as a list of dictionaries where all dictionaries (rows) must have uniform keys (column headers). Inconsistent keys may lead to unexpected table structures or errors.
- gotcha Data validation was added in v1.0.0 for robustness. If your data might not strictly adhere to expected formats, you can skip validation using the `skip_data_validation` parameter in the constructor.
- gotcha Rendering of multiline content and emojis can vary between different Markdown viewers. GitHub's markdown preview, for instance, might show slight offsets in cells containing emojis compared to a monospaced terminal.
Install
-
pip install py-markdown-table
Imports
- markdown_table
from py_markdown_table.markdown_table import markdown_table
Quickstart
from py_markdown_table.markdown_table import markdown_table
data = [
{"Product": "Smartphone", "Brand": "Apple", "Price": 999.99},
{"Product": "Laptop", "Brand": "Dell", "Price": 1299.99}
]
markdown = markdown_table(data).get_markdown()
print(markdown)