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

problem with the dataframe with long text in each cell #228

Open Shahin-rmz opened 1 year ago

Shahin-rmz commented 1 year ago

Hello, thanks for providing Tabulate. It makes life for Terminal junkies easier. I have dataframe with long text in each cell. The problem is tabulate wants to print/show all the text so it does not show the table pretty. is there a way I could show just part of the text? Thanks image

eliegoudout commented 1 year ago

One possibility is to limit the width of columns with the maxcolwidths parameter. It will still show the whole data but using multiple lines:

>>> table = ['Some text',  'Some veeeeeeeeeeeery long text']
>>> print(tabulate(table, maxcolwidths=20))
---------  --------------------
Some text  Some veeeeeeeeeeeery
           long text
---------  --------------------

I don't think there's anything to limit the number of lines in current build. It might be interesting to add this functionnality though.

I hope this helped :)

Shahin-rmz commented 1 year ago

thanks, I will try it out in next project. meantime I can ask the question in Stackoverflow and you can answer, so we earn some points :D