forked from openbci-archive/OpenBCI_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_collect.py
More file actions
39 lines (27 loc) · 695 Bytes
/
csv_collect.py
File metadata and controls
39 lines (27 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import csv
import time
class csv_collect(object):
def __init__(self, file_name="collect.csv", delim = ","):
self.file_name = file_name
self.start_time = time.time()
self.delim = delim
open(self.file_name, 'w').close()
def __call__(self, sample):
t = time.time() - self.start_time
#Print timeSinceStart|Sample Id
print("%f | %d" %(t,sample.id))
row = ''
row += str(t)
row += self.delim
row += str(sample.id)
row += self.delim
for i in sample.channel_data:
row += str(i)
row += self.delim
for i in sample.aux_data:
row += str(i)
row += self.delim
#remove last comma
row += '\n'
with open(self.file_name, 'a') as f:
f.write(row)