I'm looking at Python packages that provide an easy way to make formatted 'pretty' tables as text output. This answer provides a few suggestions. The catch is, I want to print my table sequentially (one row at a time) similar to a logger.
To illustrate, the output of tabulate is perfectly fine for my application:
from tabulate import tabulate
some_data = [['08:01', 1.00, 32], ['08:02', 1.01, 33], ['08:03', 1.02, 33]]
headers = ['Time', 'x', 'n']
print(tabulate(some_data, headers=headers, tablefmt='plain'))
Output:
Time x n
08:01 1 32
08:02 1.01 33
08:03 1.02 33
But I want to do each operation one at a time not all-at-once: 1. print the headers 2. print the first row of data 3. print the next 4. ...etc.
Of course, I tried this:
print(tabulate(some_data[0:1], tablefmt='plain'))
Output:
08:01 1 32
This obviously won't work perfectly because the formatting of each row will be different each time. So I need a package where you can set up the table first (specifying the required formats, column widths, etc). And then output data one row at a time.
Does anyone know if this is possible in one of these packages or another package that I could import?