Open pmi123 opened 1 year ago
As far as I am concerned, the tabulate module does not support dynamic row appending. The first thing that came to my mind is to regenerate the table after each row, however this would require you to clear the terminal after each section.
dac_value adc_value current_mA V_gate V_source
----------- ----------- ------------ -------- ----------
148 36 32.2266 1.9433 0.0129
148 36 64.4531 1.9433 0.0097
148 36 96.6797 1.9433 0.0129
<..........>
148 36 96.6797 1.9433 0.0129 <--- nth row
Now clear the terminal and start again.
Simple python code snippet to demonstrate my approach:
import os
from tabulate import tabulate
from time import sleep
headers = ["dac_value", "adc_value", "current_mA", "V_gate", "V_source"]
row = [148, 36, 22.558593749999993, 0.20431640624999997, 0.0012890625]
header_interval = 5
i = 0
table = []
while True:
sleep(1)
table.append(row)
os.system('cls' if os.name == 'nt' else 'clear')
print(tabulate(table, headers))
i += 1
# After each nth row clear the table
if i % header_interval == 0:
table = []
Let me know if that answers your question.
I am taking real time measurements from an ADC in a while loop, so I print one line at a time. For example,
The output looks like:
Is there a way to make it look like:
I know I could do this in my while loop (i.e. only print the data after every n rows of data is collected), but then I am not looking at the data in real time.
Thanks!