python-tabulate
python-tabulate copied to clipboard
A "matrix" table format
May I suggest adding a "matrix" table format. I'm using this one to render sparse matrices to text and it works quite well:
TableFormat(
lineabove=Line("┌", " ", " ", "┐"),
linebelowheader=Line("┌", " ", " ", "┐"),
linebetweenrows=None,
linebelow=Line("└", " ", " ", "┘"),
headerrow=DataRow(" ", " ", " "),
datarow=DataRow("│", " ", "│"),
padding=1,
with_header_hide=["lineabove"],
)
Example output:
┌ ┐
│ 3 2 │
│ 9 6 │
│ 3 1 │
│ 0 5 │
└ ┘
0 1 2 3 4 5 6
┌ ┐
│ 10 2 40 -5 24 │
└ ┘
edit: slight update to also support headers as matrix column labels