From 22726c33ce4fc08c2a7a6377b2a7139fa44ae0c1 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Thu, 29 Feb 2024 22:27:23 +0530 Subject: [PATCH] modify diagnostics data script --- scripts/diagnostics.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/diagnostics.py b/scripts/diagnostics.py index 2a58456..215ac75 100644 --- a/scripts/diagnostics.py +++ b/scripts/diagnostics.py @@ -7,7 +7,7 @@ import pandas as pd from datetime import datetime import sys -cred = credentials.Certificate(os.getcwd() + '/' + 'keys/hpos-prod-firebase-adminsdk.json') # Replace with your own service account key path +cred = credentials.Certificate(os.getcwd() + '/' + 'keys/hpos-qa-firebase-adminsdk.json') # Replace with your own service account key path firebase_admin.initialize_app(cred) db = firestore.client() @@ -28,7 +28,17 @@ df = pd.DataFrame(data) print(df) print(df.size) -# print("duplicates", len(df['_id']) - len(df['_id'].drop_duplicates())) +pattern_device_id = r'SNS\s+([^\s]+)\s+SNE' + +df['deviceId'] = df['deviceData'].str.extract(pattern_device_id) + +pattern_led = r'LED(\d+)_DAC: (\d+)' + +df_extracted = df['deviceData'].str.extractall(pattern_led).unstack().droplevel(0, axis=1) + +df_extracted.columns = [f'LED{col}_DAC' for col in df_extracted.columns] + +df = pd.concat([df, df_extracted], axis=1) output_filename = f'diagnostics_{datetime.today().strftime("%d_%m_%Y_%H_%M")}.xlsx' @@ -36,7 +46,6 @@ downloads_dir = os.path.join(os.path.expanduser("~"), "Downloads") output_path = os.path.join(downloads_dir, output_filename) writer = pd.ExcelWriter(output_path, engine = 'openpyxl') df.to_excel(writer, sheet_name = 'data', index=False) -# df_count.to_excel(writer, sheet_name = "count") writer.close() print(f"Data saved to '{output_path}'")