Open viewercq opened 4 months ago
Seems very related: I get "list index out of range" when there are no elements to tabulate and maxcolwidths
is set (e.g. tabulate([],maxcolwidths=[2])
):
File ....venv/lib/python3.12/site-packages/tabulate/__init__.py:2054, in tabulate(tabular_data, headers, tablefmt, floatfmt, intfmt, numalign, stralign, missingval, showindex, disable_numparse, colalign, maxcolwidths, rowalign, maxheadercolwidths)
2051 list_of_lists, separating_lines = _remove_separating_lines(list_of_lists)
2053 if maxcolwidths is not None:
-> 2054 num_cols = len(list_of_lists[0])
2055 if isinstance(maxcolwidths, int): # Expand scalar for all columns
2056 maxcolwidths = _expand_iterable(maxcolwidths, num_cols, maxcolwidths)
Writing here since basically the same code area/workflow
https://github.com/astanin/python-tabulate/blob/95ae5eb61ef969749e904c90ab429003238d6212/tabulate/__init__.py#L1532C27-L1532C61
str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)
tostr(cell or '') if _isnumber(cell) or cell is None else _type(cell, numparse)(cell)