combine results
This commit is contained in:
@@ -5,11 +5,10 @@ curdir = os.getcwd()
|
|||||||
path_delim = '/'
|
path_delim = '/'
|
||||||
df1 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet1")
|
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")
|
df2 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet3")
|
||||||
|
df4 = pd.read_excel(curdir + path_delim + "NagpurData_FinalResults_Aug1-a.xlsx", sheet_name="Sheet4")
|
||||||
print(df1)
|
|
||||||
print(df2)
|
|
||||||
|
|
||||||
df = df1.merge(df2, on="_id")
|
df = df1.merge(df2, on="_id")
|
||||||
|
df = df.merge(df4, on="_id")
|
||||||
df['Age'] = 2023 - df['birthYear']
|
df['Age'] = 2023 - df['birthYear']
|
||||||
print(df)
|
print(df)
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ from google.cloud.firestore_v1.base_query import FieldFilter
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
# Initialize Firebase Admin SDK
|
# 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'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)
|
firebase_admin.initialize_app(cred)
|
||||||
|
|
||||||
# Get a reference to the Firestore database
|
# Get a reference to the Firestore database
|
||||||
@@ -18,17 +19,16 @@ db = firestore.client()
|
|||||||
# Specify the collections
|
# Specify the collections
|
||||||
patient_collection = db.collection("patientData")
|
patient_collection = db.collection("patientData")
|
||||||
test_collection = db.collection("testData")
|
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): ")
|
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))
|
query = test_collection.where(filter=FieldFilter("testTime", ">=", start_date)).where(filter=FieldFilter("testTime", "<", end_date))
|
||||||
patient_docs = query.stream()
|
docs = query.stream()
|
||||||
|
|
||||||
# Prepare data to store in CSV
|
# Prepare data to store in CSV
|
||||||
data = []
|
data = []
|
||||||
for patient_doc in patient_docs:
|
for doc in docs:
|
||||||
print(patient_doc)
|
doc_data = doc.to_dict()
|
||||||
patient_data = patient_doc.to_dict()
|
|
||||||
# patient_id = patient_data["_id"]
|
# patient_id = patient_data["_id"]
|
||||||
|
|
||||||
# # Query the document from testData collection based on the common _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]
|
# combined_data[key] = patient_data[key]
|
||||||
|
|
||||||
# data.append(combined_data)
|
# data.append(combined_data)
|
||||||
data.append(patient_data)
|
data.append(doc_data)
|
||||||
|
|
||||||
# Convert the data to a DataFrame
|
# Convert the data to a DataFrame
|
||||||
df = pd.DataFrame(data)
|
df = pd.DataFrame(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user