1
0
Fork 0
Browse Source

tally readings per second using list of tuples.

This replaces the original way of doing it with a dictionary. The
change was brought about because the previous data loading function
was omitting duplicate entries (I.E. multiple readings from the same
second in time).
stable
Craig Oates 3 years ago
parent
commit
26b01f38f5
  1. 22
      src/flicker.py

22
src/flicker.py

@ -1,19 +1,19 @@
import csv
import datetime
from services import io_services, log_services
# import pdb
def tally_readings_per_second2(data):
time_tallies = dict()
for k, v in data.items():
# print(f"{k} : {v}")
# time_str = k
if (k in time_tallies):
time_tallies[k] = (time_tallies[k]) + 1
print(f"Updated {time_tallies[k]}")
for item in data:
# print(item[0])
key = item[0]
if (key in time_tallies):
time_tallies[key] = time_tallies[key] + 1
# print(f"Updated {time_tallies[key]}")
else:
time_tallies[k] = 1
# print(f"Added: {time_tallies[k]}")
# print(time_tallies)
time_tallies[key] = 1
#print(f"Added {time_tallies[key]}")
return time_tallies
def tally_readings_per_second():
@ -73,7 +73,9 @@ def main():
# rsp_above_two = get_rps_above(2, time_tallies)
# flicker_tallies = tally_flickers(rsp_above_two, time_tallies)
raw_data = io_services.load_raw_data("data/test-data-lite.csv")
log_services.print_dictionary(raw_data)
# log_services.print_list(raw_data)
time_tallies = tally_readings_per_second2(raw_data)
log_services.print_dictionary(time_tallies)
if __name__ == "__main__":
main()