Open Nekmo opened 8 years ago
Currently terminaltables doesn't wrap/truncate cells, so it doesn't set widths, widths depend on the strings in cells. Perhaps once I implement https://github.com/Robpol86/terminaltables/issues/5 I'll consider this.
If too many columns are present, the columns just overwrite on the screen. How about adding a scrollbar to CLI if too many columns come up?
This is a quick and dirty solution if the data across tables is somewhat consistent:
def equalize(tables):
""" Equalizes the columns sizes across multiple tables. """
lens = defaultdict(lambda: 0)
for table in tables:
for row in table:
for idx, cell in enumerate(row):
lens[idx] = max(lens[idx], len(cell))
for tid, table in enumerate(tables):
for rid, row in enumerate(table):
for cid, cell in enumerate(row):
tables[tid][rid][cid] = cell.ljust(lens[cid])
return tables
I have several tables and I'd like all have the same width.
My idea is to get the size of the largest and set it on all tables, but there is no method to set the width.