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

[bug] Error if trying to render a table with no rows using maxcolwidths #315

Open
elehcimd opened this issue Mar 4, 2024 · 1 comment
Open

Comments

@elehcimd
Copy link

elehcimd commented Mar 4, 2024

With tabulate==0.9.0

This code fails:

print(tabulate({'x': []}, headers="keys", maxcolwidths=100))

Expected behaviour:

Without data, it should render the table as with:

print(tabulate({'x': []}, headers="keys"))
@devdanzin
Copy link
Contributor

You can quickly fix this by editing this line:

num_cols = len(list_of_lists[0])

Into

        num_cols = len(list_of_lists[0]) if list_of_lists else 0

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