python-tabulate icon indicating copy to clipboard operation
python-tabulate copied to clipboard

problem with the dataframe with long text in each cell

Open Shahin-rmz opened this issue 3 years ago • 2 comments

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

Shahin-rmz avatar Dec 15 '22 11:12 Shahin-rmz

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 :)

eliegoudout avatar Dec 23 '22 18:12 eliegoudout

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

Shahin-rmz avatar Dec 27 '22 11:12 Shahin-rmz