diff --git a/read_arduino.py b/read_arduino.py index 3c000b7..7f98b90 100644 --- a/read_arduino.py +++ b/read_arduino.py @@ -51,7 +51,13 @@ def read(): exit(0) else: controller = serial.Serial(port, baudrate=baud) - + + # open the file and add a line of header to it, then close + f = open(file_name, "a", newline="", encoding="utf-8") + writer = csv.writer(f) + header = ['Time', 'Resistance'] + writer.writerow(header) + f.close() while controller.isOpen(): try: read_data = controller.readline().decode("utf-8")