Python library for printing pretty tables with dynamic cells
Import and create a table object like this:
from console_table import ConsoleTable
table = ConsoleTable()
table.print_entry("Heading 1", "Heading 2")
table.print_row_separator()
table.print_entry("Cell 1", ("Subcell 1", "Subcell 2"))
Which gives you this:
| Heading 1 | Heading 2 |
-------------------------------------------
| Cell 1 |Subcell 1|Subcell 2 |
As shown above, if one of the cell values provided is a tuple, the cell shall be broken up into subcells.
You can configure the table using the following parameters in the ConsoleTable constructor:
Parameter | Description | Example Value |
---|---|---|
row_format |
The format of the table row. Cell values are populated in "{}"s | "|{}|{}|" |
column_widths |
The width of the columns. If a tuple is provided, each int shall be used as the width. If the length is less than the number of cells, the last number is used for the rest of the columns | (10, 5) |
subcell_delimiter |
The character(s) to separate subcells with | ":" |
All you need to know is how to run the unit tests:
./unit_test_console_table.py