combine results
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user