Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Adamou02 opened this issue Aug 31, 2023 · 1 comment
Open

Comments

@Adamou02
Copy link

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 Adamou02 changed the title feature: Limit width of my table to the width of the console feature: Limit the width of my table based on the width of the console Aug 31, 2023
@frank-lenormand
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants