-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Description
The HTML table format renderer outputs an empty table header row when there are no data rows. This differs unexpectedly from the default text format renderer which outputs the header row regardless.
>>> from tabulate import tabulate
>>> print(tabulate([], headers=["one", "two", "three"]))
one two three
----- ----- -------
>>> print(tabulate([["a", "b", "c"]], headers=["one", "two", "three"]))
one two three
----- ----- -------
a b c
>>> print(tabulate([], headers=["one", "two", "three"], tablefmt="html"))
<table>
<thead>
<tr></tr>
</thead>
<tbody>
</tbody>
</table>
>>> print(tabulate([["a", "b", "c"]], headers=["one", "two", "three"], tablefmt="html"))
<table>
<thead>
<tr><th>one </th><th>two </th><th>three </th></tr>
</thead>
<tbody>
<tr><td>a </td><td>b </td><td>c </td></tr>
</tbody>
</table>
Expected behavior: the table header row should be populated even when there are no data rows, same as the default renderer behaves.
Metadata
Metadata
Assignees
Labels
No labels