35 lines
909 B
Python
35 lines
909 B
Python
import csv
|
|
|
|
class Reader():
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
def read_file(self, filename) -> dict:
|
|
with open(filename, 'r') as file:
|
|
data = list(csv.reader(file, delimiter=','))
|
|
|
|
# Delete metadata for now
|
|
for i in range(15):
|
|
data.pop(0)
|
|
|
|
# {'TIME': [data], 'CH1': [data], 'CH2': [data]}
|
|
channels = []
|
|
for i in range(len(data[0])):
|
|
channels.append([])
|
|
|
|
for step in data[1:]:
|
|
for idx, point in enumerate(step):
|
|
channels[idx].append(float(point))
|
|
|
|
result = {}
|
|
for idx, label in enumerate(data[0]):
|
|
result[label] = channels[idx]
|
|
|
|
return result
|
|
|
|
|
|
if __name__ == '__main__':
|
|
reader = Reader()
|
|
data = reader.read_file(r".\data\T0007ALL.csv")
|
|
print(data)
|
|
|