python-tabulate
python-tabulate copied to clipboard
stralign=None breaks table completely
I need to print table with leading spaces in some rows data (like execution plan from postgres),
the only way I found is to use stralign=None
, but it breaks the table completely for most formats
from tabulate import tabulate
print(tabulate([[" foo"], ["bar"]], stralign=None, tablefmt="pretty"))
+---------+
| foo |
| bar |
+---------+
Workaround-like is to use default stralign and replace leading spaces with something printable (any non-visible chars are stripped), so actually there is no workaround.
EXPLAIN SELECT 1 UNION SELECT 2
╭────────────────────────────────────────────────────────────╮
│ QUERY PLAN │
├────────────────────────────────────────────────────────────┤
│ Unique (cost=0.11..0.12 rows=2 width=4) │
│ ``-> Sort (cost=0.11..0.12 rows=2 width=4) │
│ ````````Sort Key: (1) │
│ ````````-> Append (cost=0.00..0.05 rows=2 width=4) │
│ ``````````````-> Result (cost=0.00..0.01 rows=1 width=4) │
│ ``````````````-> Result (cost=0.00..0.01 rows=1 width=4) │
╰────────────────────────────────────────────────────────────╯