Skip to content

Commit 3a907ab

Browse files
committed
CSV Saved with timestamp
1 parent c2280dc commit 3a907ab

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

chords.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def read_arduino_data(ser, csv_writer=None, inverted=False):
166166
channel_data.append(float(value)) # Convert to float and add to channel data
167167

168168
if csv_writer: # If CSV logging is enabled, write the data to the CSV file
169-
csv_writer.writerow([counter] + channel_data)
169+
current_timestamp = datetime.now().strftime('%H:%M:%S') # Get the current timestamp
170+
csv_writer.writerow([current_timestamp, counter] + channel_data)
170171
if lsl_outlet: # If LSL streaming is enabled, send the data to the LSL stream
171172
lsl_outlet.push_sample(channel_data)
172173

@@ -229,7 +230,7 @@ def parse_data(ser, lsl_flag=False, csv_flag=False, verbose=False, run_time=None
229230
csv_file = open(csv_filename, mode='w', newline='') if csv_flag else None # Open CSV file if logging is
230231
if csv_file:
231232
csv_writer = csv.writer(csv_file) # Create CSV writer
232-
csv_writer.writerow(['Counter', 'Channel1', 'Channel2', 'Channel3', 'Channel4', 'Channel5', 'Channel6']) # Write header
233+
csv_writer.writerow(['Timestamp', 'Counter', 'Channel1', 'Channel2', 'Channel3', 'Channel4', 'Channel5', 'Channel6']) # Write header
233234

234235
end_time = time.time() + run_time if run_time else None
235236
send_command(ser, 'START')

0 commit comments

Comments
 (0)