Convert 2D Python lists into Unicode/Ascii tables
Project description
table2ascii
Module for converting 2D Python lists to a fancy ASCII/Unicode tables
๐ฅ Installation
pip install table2ascii
๐งโ๐ป Usage
Convert Python lists to ASCII tables
from table2ascii import table2ascii
output = table2ascii(
header=["#", "G", "H", "R", "S"],
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
footer=["SUM", "130", "140", "135", "130"],
)
print(output)
"""
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ # G H R S โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
โ 1 30 40 35 30 โ
โ 2 30 40 35 30 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
โ SUM 130 140 135 130 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"""
from table2ascii import table2ascii
output = table2ascii(
body=[["Assignment", "30", "40", "35", "30"], ["Bonus", "10", "20", "5", "10"]],
first_col_heading=True,
)
print(output)
"""
โโโโโโโโโโโโโโฆโโโโโโโโโโโโโโโโโโโโ
โ Assignment โ 30 40 35 30 โ
โ Bonus โ 10 20 5 10 โ
โโโโโโโโโโโโโโฉโโโโโโโโโโโโโโโโโโโโ
"""
โ๏ธ Options
Soon table2ascii will support more options for customization.
Option | Type | Default | Description |
---|---|---|---|
first_col_heading |
bool |
False |
Whether to add a heading column seperator after the first column |
last_col_heading |
bool |
False |
Whether to add a heading column seperator before the last column |
๐จโ๐จ Use cases
Discord messages and embeds
- Display tables nicely inside markdown codeblocks on Discord
- Useful for making Discord bots with Discord.py
Terminal outputs
- Tables display nicely whenever monospace fonts are fully supported
- Tables make terminal outputs look more professional
๐งฐ Development
To run tests (pytest)
python setup.py test
To lint (flake8):
python setup.py lint
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
table2ascii-0.0.2.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for table2ascii-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd36b2458ca8964abe86fec082d0b580c22883e897e8a59793885f4ed854e5bf |
|
MD5 | a7d388e1abbc61508a09c9825da85168 |
|
BLAKE2b-256 | 25f89e26b3743bc52cae5379cfb349cf197ee5be48e9aa0784a59d31c5e7a3a8 |