From 41e3b99e0500eb932a445ecf2f08b675a9675b7d Mon Sep 17 00:00:00 2001 From: Ryan Xu Date: Thu, 15 Dec 2022 21:35:36 -0800 Subject: [PATCH] make some small changes --- read_arduino.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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")