From 5912a326d3d495933cd003f115d1744448d07c9e Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Mon, 4 Sep 2023 08:18:26 +0530 Subject: [PATCH] combine results --- scripts/combine_hemocube_denovix.py | 5 ++--- scripts/test_collection.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/combine_hemocube_denovix.py b/scripts/combine_hemocube_denovix.py index 45507c9..cc0c053 100644 --- a/scripts/combine_hemocube_denovix.py +++ b/scripts/combine_hemocube_denovix.py @@ -5,11 +5,10 @@ curdir = os.getcwd() path_delim = '/' df1 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet1") df2 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet3") - -print(df1) -print(df2) +df4 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet4") df = df1.merge(df2, on="_id") +df = df.merge(df4, on="_id") df['Age'] = 2023 - df['birthYear'] print(df) diff --git a/scripts/test_collection.py b/scripts/test_collection.py index 9702bc9..9b99d45 100644 --- a/scripts/test_collection.py +++ b/scripts/test_collection.py @@ -6,10 +6,11 @@ from google.cloud.firestore_v1.base_query import FieldFilter import pandas as pd import datetime import sys +import os # Initialize Firebase Admin SDK # cred = credentials.Certificate(r'C:\Users\smila\PycharmProjects\pythonProject\hpos-af3cc-firebase-adminsdk-n261k-2bfd463ec0.json') # Replace with your own service account key path -cred = credentials.Certificate(r'/Users/apple/Downloads/work/pythonProject-master/hpos-prod-firebase-adminsdk-bionp-3c041b2300.json') # Replace with your own service account key path +cred = credentials.Certificate(os.getcwd() + '/' + 'keys/hpos-preprod-firebase-adminsdk-d6jjt-ae42ad0f67.json') # Replace with your own service account key path firebase_admin.initialize_app(cred) # Get a reference to the Firestore database @@ -18,17 +19,16 @@ db = firestore.client() # Specify the collections patient_collection = db.collection("patientData") test_collection = db.collection("testData") -start_date = sys.argv[1] # '2023-01-12' #input("Please enter the start date (yyyy-mm-dd): ") +start_date = sys.argv[1] # '2023-09-12' #input("Please enter the start date (yyyy-mm-dd): ") end_date = sys.argv[2] #'2023-07-16' #input("Please enter the end date (yyyy-mm-dd): ") -query = patient_collection.where(filter=FieldFilter("createdAt", ">=", start_date)).where(filter=FieldFilter("createdAt", "<", end_date)) -patient_docs = query.stream() +query = test_collection.where(filter=FieldFilter("testTime", ">=", start_date)).where(filter=FieldFilter("testTime", "<", end_date)) +docs = query.stream() # Prepare data to store in CSV data = [] -for patient_doc in patient_docs: - print(patient_doc) - patient_data = patient_doc.to_dict() +for doc in docs: + doc_data = doc.to_dict() # patient_id = patient_data["_id"] # # Query the document from testData collection based on the common _id @@ -47,7 +47,7 @@ for patient_doc in patient_docs: # combined_data[key] = patient_data[key] # data.append(combined_data) - data.append(patient_data) + data.append(doc_data) # Convert the data to a DataFrame df = pd.DataFrame(data)