How can i avoid extra spaces in the tabulate grid?
rows = [
["A1", "B2"],
["C3", "D4"],
["E5", "E6"],
]
print(tabulate(rows, headers="firstrow", tablefmt='rounded_outline'))
gives me 2 extra spaces in every cell
╭──────┬──────╮
│ A1 │ B2 │
├──────┼──────┤
│ C3 │ D4 │
│ E5 │ E6 │
╰──────┴──────╯
how can i solve it to get
╭────┬────╮
│ A1 │ B2 │
├────┼────┤
│ C3 │ D4 │
│ E5 │ E6 │
╰────┴────╯
You can leverage the MIN_PADDING
constant.
import tabulate
rows = [
["A1", "B2"],
["C3", "D4"],
["E5", "E6"],
]
tabulate.MIN_PADDING = 0
print(tabulate.tabulate(rows, headers="firstrow", tablefmt="rounded_outline"))
Outputs:
╭────┬────╮
│ A1 │ B2 │
├────┼────┤
│ C3 │ D4 │
│ E5 │ E6 │
╰────┴────╯