Skip to content

Is there a way to only print the header line for every 30th line of output? #285

Description

@pmi123

I am taking real time measurements from an ADC in a while loop, so I print one line at a time. For example,

while True:
{measure data}
table=[[148, 36, 22.558593749999993, 0.20431640624999997, 0.0012890625]] # one row of data
table_header = ["dac_value, adc_value, current_mA, V_gate, V_source"]
print(tabulate(table, table_header))

The output looks like:

  dac_value    adc_value    current_mA    V_gate    V_source
-----------  -----------  ------------  --------  ----------
        148           36       32.2266    1.9433      0.0129
  dac_value    adc_value    current_mA    V_gate    V_source
-----------  -----------  ------------  --------  ----------
        148           36       64.4531    1.9433      0.0097
  dac_value    adc_value    current_mA    V_gate    V_source
-----------  -----------  ------------  --------  ----------
        148           36       96.6797    1.9433      0.0129
  dac_value    adc_value    current_mA    V_gate    V_source
-----------  -----------  ------------  --------  ----------
        148           36       161.133    1.9433      0.0129

Is there a way to make it look like:

  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

  dac_value    adc_value    current_mA    V_gate    V_source <-- add this header every nth line of data
-----------  -----------  ------------  --------  ----------
        148           36       161.133    1.9433      0.0129

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions