add sample in testsData
This commit is contained in:
27
scripts/add_sample.py
Normal file
27
scripts/add_sample.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from google.cloud import firestore
|
||||
import json
|
||||
|
||||
# Replace 'your-project-id' with your actual project ID
|
||||
# Make sure to set up your Google Cloud credentials
|
||||
# Information on setting up credentials: https://cloud.google.com/docs/authentication
|
||||
project_id = 'hpos-qa'
|
||||
|
||||
# Initialize Firestore client
|
||||
db = firestore.Client(project=project_id)
|
||||
|
||||
# Replace 'your-collection' with the name of your Firestore collection
|
||||
collection_name = 'testData'
|
||||
|
||||
# JSON data as a string
|
||||
json_data_string = '{"_id":"1707403811SMIBLR","abhaId":"12434949797979","abs1":0.786217137019524,"abs2":0.16870115026724458,"abs3":-16.373758223468197,"abs4":0.9129641832402621,"appVersion":"2.1.103","batteryCapacity":"-2147483648","batteryLevel":"100.0","batteryMaxCapacity":"-Infinity","batteryTemperature":"42.4","batteryVoltage":"0.0","birthYear":"2000","bloodGroup":"","calculatedRatio":0,"classificationResult":"Normal","coefficients":"null, null","concentration":"","csvcreated":false,"deviceId":"HCV-000-5003","deviceRatio":0.2145732296128458,"deviceRatioClass":"Normal","deviceSerialNumber":"ADMIN","deviceType":"HEMOCUBE","errorMessages":"Calibration configuration for this device id is not found\nError: Invalid Test. Improper buffer reading (low)Error: Low Hb. Repeat test\n","gender":"Male","hb3":null,"hb4":null,"incubationTime":"","kitSerial":"SMI/SC/000/00/000","led1Air1":null,"led1Air2":null,"led1Average":0.786217137019524,"led1Buffer":21901,"led1Gain1":null,"led1Gain2":null,"led1Gain3":null,"led1Gain4":null,"led1Sample":3583,"led2Air1":null,"led2Air2":null,"led2Average":0.16870115026724458,"led2Buffer":17801,"led2Gain1":null,"led2Gain2":null,"led2Gain3":null,"led2Gain4":null,"led2Sample":12071,"led3Air1":null,"led3Air2":null,"led3Average":0.18302695903344623,"led3Buffer":17831,"led3Gain1":null,"led3Gain2":null,"led3Gain3":null,"led3Gain4":null,"led3Sample":11699,"led4Air1":null,"led4Air2":null,"led4Average":0.9129641832402621,"led4Buffer":21753,"led4Gain1":null,"led4Gain2":null,"led4Gain3":null,"led4Gain4":null,"led4Sample":2658,"localFlag":false,"location":null,"molbioFlag":false,"name":"4 ml 4% 6 ul T21","prdClassification":"Invalid","predictedDenovixRatio":-20.826000162677186,"quickCapture":false,"reportUploadTime":"2024-02-08 20:22:48","resultData":"SNS HCV-000-5003 SNE\r\n#SS1\r\n#SC1\r\nRESULT \r\nLB1 21901.00\r\nLB2 17801.00\r\nLB3 17831.00\r\nLB4 21753.00\r\nLS1 3583.00\r\nLS2 12071.00\r\nLS3 11699.00\r\nLS4 2658.00\r\nREND\r\n","slopeRatio":26.62013124525849,"slopeRatioClass":"Normal","solution":"","state":"Karnataka","testStatus":true,"testTime":"2024-02-08 20:22:48","testType":"HEMOCUBE","userImageURL":"https://hpos-prod.web.app/logo.png","volume":""}'
|
||||
|
||||
# Replace invalid characters with spaces
|
||||
cleaned_json_data_string = ''.join(char if 32 <= ord(char) <= 126 else ' ' for char in json_data_string)
|
||||
|
||||
# Convert cleaned JSON string to Python dictionary
|
||||
data = json.loads(cleaned_json_data_string)
|
||||
|
||||
# Add a new document with an automatically generated ID
|
||||
doc_ref = db.collection(collection_name).add(data)
|
||||
|
||||
print(f'Document added with ID: {doc_ref.id}')
|
||||
Reference in New Issue
Block a user