I have a sensor which prints to my COM4 port. I can read from this using serial
like:
import serial
ser = serial.Serial('COM4')
while True:
if ser.in_waiting > 0:
temp = ser.readline()
print(temp)
Is there an efficient way to write this to a CSV file instead of printing to the console?
The problem I'm experiencing is if I stop the script midstream then the changes to the file seem to get thrown away, even if I include a step of writing the header in before the while True
loop.