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 details)
Built Distribution
File details
Details for the file table2ascii-0.0.2.tar.gz
.
File metadata
- Download URL: table2ascii-0.0.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 773cdb9e841fa3ca04b745326010c377a8a62624ddcb4fd0c44df7290b9827c4 |
|
MD5 | b422ae6e35133834ff2de665257c134d |
|
BLAKE2b-256 | 1bc9cfc83c1389d36f7972a1a617b1512c0debf393f46a95c56f6b07dc784654 |
File details
Details for the file table2ascii-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: table2ascii-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd36b2458ca8964abe86fec082d0b580c22883e897e8a59793885f4ed854e5bf |
|
MD5 | a7d388e1abbc61508a09c9825da85168 |
|
BLAKE2b-256 | 25f89e26b3743bc52cae5379cfb349cf197ee5be48e9aa0784a59d31c5e7a3a8 |