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

IndexError on empty tables when `maxheadercolwidths` is used

Open Ronserruya opened this issue 9 months ago • 1 comments

Whenever the parameter maxheadercolwidths is not None, an IndexError is raised when trying to print an empty table

The issue specifically is here: https://github.com/astanin/python-tabulate/blob/master/tabulate/init.py#L2253

if maxheadercolwidths is not None:
    num_cols = len(list_of_lists[0])

where with an empty table list_of_lists is empty

Ronserruya avatar Apr 06 '25 14:04 Ronserruya