modify diagnostics data script
This commit is contained in:
@@ -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}'")
|
||||
|
||||
Reference in New Issue
Block a user