python-tabulate
python-tabulate copied to clipboard
feature: Limit the width of my table based on the width of the console
Description
Error occurs when I print a table larger than my console output.
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
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.