Right now, the print line reads a voltage from my sensor and prints it on the screen every 50ms. I want to output this to a CSV file when the code gets interrupted. I read other tutorials on how to output to a CSV file when the output is already determined, but I cannot figure out how to write to a csv file when I need to read live voltage.
This is the answer that I cannot manage to adapt to my code: writing print output to csv file
from ABE_ADCDACPi import ADCDACPi
import time
adcdac = ADCDACPi()
adcdac.set_adc_refvoltage(3.3)
while True:
print (adcdac.read_adc_voltage(1, 0))
time.sleep(0.05)
EDIT: This is not the same using VBA to merge CSV files. I am writing from a sensor to an ADC to a microcontroller to RAM to CSV.