combine results

This commit is contained in:
Pritimay Sarkar
2023-09-04 08:18:26 +05:30
parent 907129d673
commit 5912a326d3
2 changed files with 10 additions and 11 deletions

View File

@@ -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)

View File

@@ -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)