astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.11k stars 163 forks source link

simple_grid format does not work on Linux #199

Closed psads-git closed 1 year ago

psads-git commented 1 year ago

Take the following code:

from tabulate import tabulate

table = [["spam",42],["eggs",451],["bacon",0]]
headers = ["item", "qty"]
print(tabulate(table, headers, tablefmt="simple_grid"))

Its output is:

item      qty
------  -----
spam       42
eggs      451
bacon       0

when it should be:

┌────────┬───────┐
│ item   │   qty │
├────────┼───────┤
│ spam   │    42 │
├────────┼───────┤
│ eggs   │   451 │
├────────┼───────┤
│ bacon  │     0 │
└────────┴───────┘
astanin commented 1 year ago

I just checked, it works on Linux too.

Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from tabulate import tabulate
>>> table = [["spam",42],["eggs",451],["bacon",0]]
"item">>> headers = ["item", "qty"]
>>> print(tabulate(table, headers, tablefmt="simple_grid"))
┌────────┬───────┐
│ item   │   qty │
├────────┼───────┤
│ spam   │    42 │
├────────┼───────┤
│ eggs   │   451 │
├────────┼───────┤
│ bacon  │     0 │
└────────┴───────┘
>>> import tabulate as t
>>> t.__version__
'0.9.0'

Please note that simple_grid was added after 0.8.10. So unless you're using the git version, 0.9.0 is the first public PyPI release which supports it.