Craig Oates
3 years ago
1 changed files with 31 additions and 22 deletions
@ -1,27 +1,36 @@ |
|||||||
import csv |
import csv |
||||||
import datetime |
import datetime |
||||||
|
|
||||||
time_tallies = dict() |
def tally_readings_per_second(): |
||||||
tally_totals = dict() |
time_tallies = dict() |
||||||
|
tally_totals = dict() |
||||||
with open("data/test-data.csv") as csv_file: |
with open("data/test-data.csv") as csv_file: |
||||||
csv_reader = csv.reader(csv_file, delimiter=",") |
csv_reader = csv.reader(csv_file, delimiter=",") |
||||||
for r in csv_reader: |
for r in csv_reader: |
||||||
if (r[1] != "Time Stamp"): |
if (r[1] != "Time Stamp"): |
||||||
time_str = r[1] |
time_str = r[1] |
||||||
if (time_str in time_tallies): |
if (time_str in time_tallies): |
||||||
time_tallies[time_str] = (time_tallies[time_str]) + 1 |
time_tallies[time_str] = (time_tallies[time_str]) + 1 |
||||||
|
else: |
||||||
|
time_tallies[time_str] = 1 |
||||||
|
for r2 in time_tallies.values(): |
||||||
|
if (r2 in tally_totals): |
||||||
|
tally_totals[r2] = (tally_totals[r2]) + 1 |
||||||
else: |
else: |
||||||
time_tallies[time_str] = 1 |
tally_totals[r2] = 1 |
||||||
for r2 in time_tallies.values(): |
# print(tally_totals.items()) |
||||||
if (r2 in tally_totals): |
return tally_totals |
||||||
tally_totals[r2] = (tally_totals[r2]) + 1 |
|
||||||
else: |
def save_tally_totals(tally_totals): |
||||||
tally_totals[r2] = 1 |
with open("data/results/readings-per-sec.csv", mode="w") as result: |
||||||
print(tally_totals.items()) |
wtr = csv.writer(result) |
||||||
with open("data/results/reading-per-sec.csv", mode="w") as result: |
for k, v in tally_totals.items(): |
||||||
wtr = csv.writer(result) |
print(f"{k}: {v}") |
||||||
for k, v in tally_totals.items(): |
wtr.writerow([k,v]) |
||||||
print(f"{k}: {v}") |
|
||||||
wtr.writerow([k,v]) |
|
||||||
|
|
||||||
|
def main(): |
||||||
|
time_tallies = tally_readings_per_second() |
||||||
|
save_tally_totals(time_tallies) |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
main() |
||||||
|
Reference in new issue