astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.08k stars 162 forks source link

SEPARATING_LINE doesn't work with grid table formats #328

Open lingrlongr opened 2 months ago

lingrlongr commented 2 months ago

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
---  ---
GuidoBartoli commented 1 month ago

Take a look at #322, too.