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

SEPARATING_LINE doesn't work with grid table formats

Open lingrlongr opened this issue 1 year ago • 1 comments

When using grid table formats to style a table, you get distorted results.

For example, this script:

import tabulate

rows = [
    ['foo', 'bar'],
    ['foo', 'bar'],
    tabulate.SEPARATING_LINE,
    ['foo', 'bar'],
    ['foo', 'bar'],
]

print(tabulate.tabulate(rows, tablefmt='rounded_grid'))

When using rounded_grid, it renders:

╭─────┬─────╮
│ foo │ bar │
├─────┼─────┤
│ foo │ bar │
├─────┼─────┤
│  │
├─────┼─────┤
│ foo │ bar │
├─────┼─────┤
│ foo │ bar │
╰─────┴─────╯

When using grid, it renders:

+-----+-----+
| foo | bar |
+-----+-----+
| foo | bar |
+-----+-----+
|  |
+-----+-----+
| foo | bar |
+-----+-----+
| foo | bar |
+-----+-----+

When using the default non-grid format, it renders:

---  ---
foo  bar
foo  bar
---  ---
foo  bar
foo  bar
---  ---

lingrlongr avatar Jun 10 '24 20:06 lingrlongr

Take a look at #322, too.

GuidoBartoli avatar Jul 15 '24 15:07 GuidoBartoli