From 4d29f78c8562e12e34cadd132d4a688606b34e42 Mon Sep 17 00:00:00 2001 From: "Thomas J. Kennedy" <tkennedy@cs.odu.edu> Date: Wed, 19 Oct 2022 16:31:17 -0400 Subject: [PATCH] Tweak Semester Project Input example --- .../python3/parseTempsDemo.py | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/SemesterProject-CPU-Temps/python3/parseTempsDemo.py b/SemesterProject-CPU-Temps/python3/parseTempsDemo.py index 132268a..ecb4c9e 100755 --- a/SemesterProject-CPU-Temps/python3/parseTempsDemo.py +++ b/SemesterProject-CPU-Temps/python3/parseTempsDemo.py @@ -15,34 +15,45 @@ def main(): input_temps = sys.argv[1] with open(input_temps, 'r') as temps_file: + # ---------------------------------------------------------------------- # Output raw structure - # for temps_as_floats in parse_raw_temps(temps_file): - # print(temps_as_floats) + # ---------------------------------------------------------------------- + for temps_as_floats in parse_raw_temps(temps_file): + print(temps_as_floats) + with open(input_temps, 'r') as temps_file: + # ---------------------------------------------------------------------- # Split data - # for temps_as_floats in parse_raw_temps(temps_file): - # time, core_data = temps_as_floats - # print(f"{time = } | {core_data = }") + # ---------------------------------------------------------------------- + for temps_as_floats in parse_raw_temps(temps_file): + time, core_data = temps_as_floats + print(f"{time = } | {core_data = }") + with open(input_temps, 'r') as temps_file: + # ---------------------------------------------------------------------- # Split Data - # times = [] - # core_0_data = [] - # core_1_data = [] - # core_2_data = [] - # core_3_data = [] - # for time, core_data in parse_raw_temps(temps_file): - # times.append(time) - # core_0_data.append(core_data[0]) - # core_1_data.append(core_data[1]) - # core_2_data.append(core_data[2]) - # core_3_data.append(core_data[3]) - - # print(f"{times[:4] = }") - # print(f"{core_0_data[:4] = }") - # for time, *temps in list(zip(times, core_0_data, core_1_data, core_2_data, core_3_data))[4:]: - # print(f"{time=} {temps=}") + # ---------------------------------------------------------------------- + times = [] + core_0_data = [] + core_1_data = [] + core_2_data = [] + core_3_data = [] + for time, core_data in parse_raw_temps(temps_file): + times.append(time) + core_0_data.append(core_data[0]) + core_1_data.append(core_data[1]) + core_2_data.append(core_data[2]) + core_3_data.append(core_data[3]) + print(f"{times[:4] = }") + print(f"{core_0_data[:4] = }") + for time, *temps in list(zip(times, core_0_data, core_1_data, core_2_data, core_3_data))[4:]: + print(f"{time=} {temps=}") + + with open(input_temps, 'r') as temps_file: + # ---------------------------------------------------------------------- # Split Data, but Better! + # ---------------------------------------------------------------------- times = [] core_data = [[] for _ in range(0, 4)] -- GitLab