All Projects β†’ DenverCoder1 β†’ table2ascii

DenverCoder1 / table2ascii

Licence: MIT license
Python library for converting lists to fancy ASCII tables for displaying in the terminal and on Discord

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to table2ascii

Portable Utf8
πŸ‰‘ Portable UTF-8 library - performance optimized (unicode) string functions for php.
Stars: ✭ 405 (+1206.45%)
Mutual labels:  unicode, ascii
Git Praise
A nicer git blame.
Stars: ✭ 24 (-22.58%)
Mutual labels:  unicode, pretty-print
Transliteration
UTF-8 to ASCII transliteration / slugify module for node.js, browser, Web Worker, React Native, Electron and CLI.
Stars: ✭ 444 (+1332.26%)
Mutual labels:  unicode, ascii
attic
A collection of personal tiny tools - mirror of https://gitlab.com/hydrargyrum/attic
Stars: ✭ 17 (-45.16%)
Mutual labels:  unicode, ascii
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (+509.68%)
Mutual labels:  unicode, ascii
durdraw
Animated Unicode, ANSI and ASCII Art Editor for Linux/Unix/macOS
Stars: ✭ 55 (+77.42%)
Mutual labels:  unicode, ascii
Slug Generator
Slug Generator Library for PHP, based on Unicode’s CLDR data
Stars: ✭ 740 (+2287.1%)
Mutual labels:  unicode, ascii
Webpack Messages
Beautifully format Webpack messages throughout your bundle lifecycle(s)!
Stars: ✭ 238 (+667.74%)
Mutual labels:  formatter, pretty-print
Unibits
Visualize different Unicode encodings in the terminal
Stars: ✭ 125 (+303.23%)
Mutual labels:  unicode, ascii
Lehar
Visualize data using relative ordering
Stars: ✭ 81 (+161.29%)
Mutual labels:  unicode, ascii
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (+0%)
Mutual labels:  unicode, formatter
dart-more
More Dart β€” Literally.
Stars: ✭ 81 (+161.29%)
Mutual labels:  formatter, utilities
characteristics
Character info under different encodings
Stars: ✭ 25 (-19.35%)
Mutual labels:  unicode, ascii
unidecode
Elixir package to transliterate Unicode to ASCII
Stars: ✭ 18 (-41.94%)
Mutual labels:  unicode, ascii
homoglyphs
Homoglyphs: get similar letters, convert to ASCII, detect possible languages and UTF-8 group.
Stars: ✭ 70 (+125.81%)
Mutual labels:  unicode, ascii
Urlify
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.
Stars: ✭ 633 (+1941.94%)
Mutual labels:  unicode, ascii
util
封装了一些JavaεΈΈη”¨ηš„εŠŸθƒ½
Stars: ✭ 19 (-38.71%)
Mutual labels:  formatter, utils
Pretty Yaml
PyYAML-based module to produce pretty and readable YAML-serialized data
Stars: ✭ 110 (+254.84%)
Mutual labels:  formatter, pretty-print
Weird Json
A collection of strange encoded JSONs. For connoisseurs.
Stars: ✭ 53 (+70.97%)
Mutual labels:  unicode, ascii
Cowsay Files
A collection of additional/alternative cowsay files.
Stars: ✭ 216 (+596.77%)
Mutual labels:  unicode, ascii

table2ascii

build version downloads license discord

Library for converting 2D Python lists to fancy ASCII/Unicode tables

Documentation and examples are available at table2ascii.rtfd.io

πŸ“₯ Installation

pip install -U table2ascii

Requirements: Python 3.7+

πŸ§‘β€πŸ’» Usage

πŸš€ Convert 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 β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
"""

πŸ† Set first or last column headings

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 β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
"""

πŸ“° Set column widths and alignments

from table2ascii import table2ascii, Alignment

output = table2ascii(
    header=["#", "G", "H", "R", "S"],
    body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
    first_col_heading=True,
    column_widths=[5, 5, 5, 5, 5],
    alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4,
)

print(output)

"""
╔═════╦═══════════════════════╗
β•‘ #   β•‘   G     H     R     S β•‘
β•Ÿβ”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•’
β•‘ 1   β•‘  30    40    35    30 β•‘
β•‘ 2   β•‘  30    40    35    30 β•‘
β•šβ•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
"""

🎨 Use a preset style

See a list of 30+ preset styles here.

from table2ascii import table2ascii, Alignment, PresetStyle

output = table2ascii(
    header=["First", "Second", "Third", "Fourth"],
    body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
    column_widths=[10, 10, 10, 10],
    style=PresetStyle.ascii_box
)

print(output)

"""
+----------+----------+----------+----------+
|  First   |  Second  |  Third   |  Fourth  |
+----------+----------+----------+----------+
|    10    |    30    |    40    |    35    |
+----------+----------+----------+----------+
|    20    |    10    |    20    |    5     |
+----------+----------+----------+----------+
"""

output = table2ascii(
    header=["First", "Second", "Third", "Fourth"],
    body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
    style=PresetStyle.plain,
    cell_padding=0,
    alignments=[Alignment.LEFT] * 4,
)

print(output)

"""
First Second Third Fourth
10    30     40    35
20    10     20    5
"""

🎲 Define a custom style

Check TableStyle for more info and PresetStyle for examples.

from table2ascii import table2ascii, TableStyle

my_style = TableStyle.from_string("*-..*||:+-+:+     *''*")

output = table2ascii(
    header=["First", "Second", "Third"],
    body=[["10", "30", "40"], ["20", "10", "20"], ["30", "20", "30"]],
    style=my_style
)

print(output)

"""
*-------.--------.-------*
| First : Second : Third |
+-------:--------:-------+
|  10   :   30   :  40   |
|  20   :   10   :  20   |
|  30   :   20   :  30   |
*-------'--------'-------*
"""

βš™οΈ Options

All parameters are optional.

Option Type Default Description
header List[Any] None First table row seperated by header row seperator. Values should support str().
body List[List[Any]] None List of rows for the main section of the table. Values should support str().
footer List[Any] None Last table row seperated by header row seperator. Values should support str().
column_widths List[Optional[int]] None (automatic) List of column widths in characters for each column
alignments List[Alignment] None (all centered) Column alignments
(ex. [Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT])
style TableStyle double_thin_compact Table style to use for the table*
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
cell_padding int 1 The minimum number of spaces to add between the cell content and the cell border.

*See a list of all preset styles here.

See the API Reference for more info.

πŸ‘¨β€πŸŽ¨ Use cases

πŸ—¨οΈ Discord messages and embeds

  • Display tables nicely inside markdown code blocks on Discord
  • Useful for making Discord bots with Discord.py

image

πŸ’» Terminal outputs

  • Tables display nicely whenever monospace fonts are fully supported
  • Tables make terminal outputs look more professional

image

πŸ€— Contributing

Contributions are welcome!

See CONTRIBUTING.md for more details on how to get involved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].