take only test collection data

This commit is contained in:
Pritimay Sarkar
2023-08-25 13:31:28 +05:30
parent 9f3689f22e
commit 70b339b93e
2 changed files with 28 additions and 43 deletions

View File

@@ -56,32 +56,17 @@ def consolidation(request):
db = firestore.client()
patient_collection = db.collection("patientData")
test_collection = db.collection("testData")
query = test_collection
patient_docs = query.stream()
data = []
for patient_doc in patient_docs:
patient_data = patient_doc.to_dict()
patient_id = patient_data["_id"]
test_docs = test_collection.where("_id", "==", patient_id).stream()
for test_doc in test_docs:
test_data = test_doc.to_dict()
combined_data = {**patient_data, **test_data}
for key, value in combined_data.items():
if value == "" and key in patient_data:
combined_data[key] = patient_data[key]
data.append(combined_data)
test_docs = test_collection.stream()
for test_doc in test_docs:
print(test_doc)
test_data = test_doc.to_dict()
data.append(test_data)
df = pd.DataFrame(data)
df = df.drop_duplicates()
output_filename = f'data_{datetime.today().strftime("%d_%m_%Y_%H_%M")}.xlsx'
@@ -98,8 +83,6 @@ def consolidation(request):
# firebase_admin.delete_app(firebase_admin.get_app())
# return 'df size {}!'.format(df.size)
with open(output_path,'rb') as f:
file_data = io.BytesIO(f.read())