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

feature: Limit the width of my table based on the width of the console

Open Adamou02 opened this issue 2 years ago • 1 comments

Description

Error occurs when I print a table larger than my console output.

image

Problem, I do not know in advance the number of columns in my tabulate table

Expected behavior

Actually, I have this line :

print(tabulate(data_results, headers="keys", tablefmt="fancy_grid", maxcolwidths=30, showindex=False))

I would like to replace the maxcolwidths=30 with maxcolwidths='automatic'.

This flag will adapt the size of the columns according to the formula console width / number of columns

Adamou02 avatar Aug 31 '23 08:08 Adamou02

I’m experiencing the same issue, and I believe this to be a bug.

The engine allows columns to be rendered with a width greater than the value of maxcolwidths, when their contents do not exceed that limit.

For example, an empty cell, or one that doesn’t have contents exceeding maxcolwidths codepoints.

frank-lenormand avatar Sep 15 '23 08:09 frank-lenormand