jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.35k stars 154 forks source link

Divider functionality not / no longer working #240

Closed BWotka closed 1 year ago

BWotka commented 1 year ago

This example from the readMe does not run:

from prettytable import PrettyTable

x = PrettyTable()
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
x.add_row(["Adelaide", 1295, 1158259, 600.5])
x.add_row(["Brisbane", 5905, 1857594, 1146.4])
x.add_row(["Darwin", 112, 120900, 1714.7])
x.add_row(["Hobart", 1357, 205556, 619.5], divider=True)
x.add_row(["Melbourne", 1566, 3806092, 646.9])
x.add_row(["Perth", 5386, 1554769, 869.4])
x.add_row(["Sydney", 2058, 4336374, 1214.8])

add_row() does not even have a divider parameter. While this gets fixed/ the readMe adapted: Is there any other way to get the displayed behaviour?

BWotka commented 1 year ago

I just found the commit which belongs to the feature. Its very new and i guess not yet available (neither from normal pip nor via pip&git), tested 5mins ago. Please adapt the readMe to show that this feature is not yet usable.

hugovk commented 1 year ago

I think you're using an old version, it works for me with the latest 3.7.0:

>>> from prettytable import PrettyTable
>>>
>>> x = PrettyTable()
>>> x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
>>> x.add_row(["Adelaide", 1295, 1158259, 600.5])
>>> x.add_row(["Brisbane", 5905, 1857594, 1146.4])
>>> x.add_row(["Darwin", 112, 120900, 1714.7])
>>> x.add_row(["Hobart", 1357, 205556, 619.5], divider=True)
>>> x.add_row(["Melbourne", 1566, 3806092, 646.9])
>>> x.add_row(["Perth", 5386, 1554769, 869.4])
>>> x.add_row(["Sydney", 2058, 4336374, 1214.8])
>>> x
+-----------+------+------------+-----------------+
| City name | Area | Population | Annual Rainfall |
+-----------+------+------------+-----------------+
|  Adelaide | 1295 |  1158259   |      600.5      |
|  Brisbane | 5905 |  1857594   |      1146.4     |
|   Darwin  | 112  |   120900   |      1714.7     |
|   Hobart  | 1357 |   205556   |      619.5      |
+-----------+------+------------+-----------------+
| Melbourne | 1566 |  3806092   |      646.9      |
|   Perth   | 5386 |  1554769   |      869.4      |
|   Sydney  | 2058 |  4336374   |      1214.8     |
+-----------+------+------------+-----------------+
>>> from prettytable import __version__
>>> __version__
'3.7.0'
>>>

What versions are you using?

BWotka commented 1 year ago

It was infact a version problem, i was using 3.6.0 . Now works under 3.7.0. i had run python -m pip install -U git+https://github.com/jazzband/prettytable but only pip install --upgrade prettytable actually updated the version. The other command only told me 'requirement already satisfied'