From 5d0912aa843fd343fe7f774c556f258c004d7b91 Mon Sep 17 00:00:00 2001 From: tonydero Date: Tue, 14 Jan 2025 15:04:03 -0700 Subject: [PATCH] test view keys --- data-view.py | 13 +++++++------ data.py | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/data-view.py b/data-view.py index 4cc7803..f3aac71 100644 --- a/data-view.py +++ b/data-view.py @@ -18,18 +18,19 @@ root_dir = "/home/tonydero/projects/weather-pydash/" sensors_dict = pd.read_pickle(root_dir+"output/saved_sensors_dict.pkl") none_dict = nan2None(sensors_dict) -none_df = pd.DataFrame(none_dict) +print(none_dict.keys()) +# none_df = pd.DataFrame(none_dict) -with open(root_dir+'output/none_dict.json', 'w', encoding='utf-8') as f: - json.dump(none_dict, f, ensure_ascii=False, indent=4) +# with open(root_dir+'output/none_dict.json', 'w', encoding='utf-8') as f: +# json.dump(none_dict, f, ensure_ascii=False, indent=4) # sensors_df = pd.DataFrame(sensors_dict) # sensors_df.T.to_csv("sensors_df.csv") # print(datetime.now().strftime("%s")) -none_df.T.to_csv(root_dir+"output/none_df.csv") +# none_df.T.to_csv(root_dir+"output/none_df.csv") -none_read_df = pd.read_csv(root_dir+"output/none_df.csv") -print(none_read_df) +# none_read_df = pd.read_csv(root_dir+"output/none_df.csv") +# print(none_read_df) # concat_df = pd.concat([none_read_df, none_read_df], ignore_index=True) # print(concat_df.tail()) diff --git a/data.py b/data.py index a87f1dd..4e60389 100644 --- a/data.py +++ b/data.py @@ -21,6 +21,7 @@ def convert_int(value): return None +root_dir = "/home/tonydero/projects/weather-pydash/" sensors_url = "http://192.168.1.221/get_livedata_info" sensors_response = requests.get(sensors_url) @@ -36,7 +37,7 @@ broom_dict = sensors_dict['ch_aisle'][4] lightning_dict = sensors_dict['lightning'][0] try: - with open('/home/tonydero/projects/weather-pydash/output/saved_sensors_dict.pkl', 'rb') as f: + with open(root_dir+'output/saved_sensors_dict.pkl', 'rb') as f: sensors_dict = pickle.load(f) except: sensors_dict = {} @@ -69,7 +70,7 @@ datum_dict['lghtng_batt'] = convert_int(lightning_dict['battery']) sensors_dict[datetime.now()] = datum_dict -with open('/home/tonydero/projects/weather-pydash/output/saved_sensors_dict.pkl', 'wb') as f: +with open(root_dir+'output/saved_sensors_dict.pkl', 'wb') as f: pickle.dump(sensors_dict, f) -with open('/home/tonydero/projects/weather-pydash/output/saved_sensors_dict.json', 'w', encoding='utf-8') as f: +with open(root_dir+'output/saved_sensors_dict.json', 'w', encoding='utf-8') as f: json.dump(sensors_dict, f, ensure_ascii=False, indent=4)