Skip to content

less verbose grids #1

@anarcat

Description

@anarcat

Hi!

I'd love to have a "less verbose" fancy grid layout. this, for example, seems counter-intuitive:

#!/usr/bin/python3

import tabulate

table = [["spam",42],["eggs",451],["bacon",0]]
headers = ["item", "qty"]

print(tabulate.tabulate(table, headers, tablefmt="simple"))
print(tabulate.tabulate(table, headers, tablefmt="fancy_grid"))
$ python3 ~/bin/test-tabulate.py 
item      qty
------  -----
spam       42
eggs      451
bacon       0
╒════════╤═══════╕
│ item   │   qty │
╞════════╪═══════╡
│ spam   │    42 │
├────────┼───────┤
│ eggs   │   451 │
├────────┼───────┤
│ bacon  │     0 │
╘════════╧═══════╛

ie. why are there separators between the lines in the second table and not the first? it makes tables really (needlessly, IMHO) long. i would prefer it like this:

#!/usr/bin/python3

import tabulate

table = [["spam",42],["eggs",451],["bacon",0]]
headers = ["item", "qty"]

fancy_grid_nogap = tabulate.TableFormat(lineabove=tabulate.Line("╒", "═", "╤", "╕"),
                                        linebelowheader=tabulate.Line("╞", "═", "╪", "╡"),
                                        linebetweenrows=None,
                                        linebelow=tabulate.Line("╘", "═", "╧", "╛"),
                                        headerrow=tabulate.DataRow("│", "│", "│"),
                                        datarow=tabulate.DataRow("│", "│", "│"),
                                        padding=1, with_header_hide=None)

print(tabulate.tabulate(table, headers, tablefmt="simple"))
print(tabulate.tabulate(table, headers, tablefmt=fancy_grid_nogap))
$ python3 ~/bin/test-tabulate.py 
item      qty
------  -----
spam       42
eggs      451
bacon       0
╒════════╤═══════╕
│ item   │   qty │
╞════════╪═══════╡
│ spam   │    42 │
│ eggs   │   451 │
│ bacon  │     0 │
╘════════╧═══════╛

and while, yes, i found out I can do that myself, I was wondering if you would welcome a PR that would do so. :)

thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions