python-tabulate
python-tabulate copied to clipboard
Bug: SEPARATING_LINE does not work with headers="keys"
tabulate.SEPARATING_LINE does not work when the table consists of dictionaries and keys are used as headers:
>>> table = [{"name": "Ben"}, {"name": "Adam"}]
>>> print(tabulate.tabulate(table, headers="keys"))
name
------
Ben
Adam
>>> table = [{"name": "Ben"}, tabulate.SEPARATING_LINE, {"name": "Adam"}]
>>> print(tabulate.tabulate(table, headers="keys"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fui4fe/.local/lib/python3.10/site-packages/tabulate/__init__.py", line 2048, in tabulate
list_of_lists, headers = _normalize_tabular_data(
File "/home/fui4fe/.local/lib/python3.10/site-packages/tabulate/__init__.py", line 1409, in _normalize_tabular_data
for k in row.keys():
AttributeError: 'str' object has no attribute 'keys'
Expected behaivour:
>>> table = [{"name": "Ben"}, tabulate.SEPARATING_LINE, {"name": "Adam"}]
>>> print(tabulate.tabulate(table, headers="keys"))
name
------
Ben
------
Adam