From b149ce3a8d393ee6f88c83d123e90a7ea7bedb9e Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 8 May 2021 16:02:14 +0100 Subject: [PATCH] change return type to list in load_raw_data. I made the mistake of not realising the dictionary was 'removing' duplicate entries by simply not adding the 'second' reading for a given time interval. An example of this is as follows, there are two readings within the fifty-sixth second (E.G. 07:03:56) but the second was being omitted from the dictionary storing the data after it was loaded into memory. I changed the return type to a list of tuples to preserve the raw part of the data (I.E. multiple readings per second). The intention here is so I can start from the 'raw' data without needing to load the data in numerous times during run-time. I've omitted the 'Id' column because I have no need for it in this context. If I do need it, though, I can add an extra item to the returned tuple (I.E. add r[0] to append) . This bug came about because I took most of the code from the initial 'load data' function. The original function converted the raw CSV data into a dictionary which tallied the total readings per second before returning it. This function doesn't do that. It leaves the data in a more raw state. --- src/services/io_services.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/io_services.py b/src/services/io_services.py index 5664b45..532cb07 100644 --- a/src/services/io_services.py +++ b/src/services/io_services.py @@ -2,10 +2,10 @@ import csv import datetime def load_raw_data(path): - data = dict() + data = list() with open(path) as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") for r in csv_reader: if (r[1] != "Time Stamp"): - data[r[1]] = r[2] + data.append( (r[1], r[2]) ) return data