I am quite new to python and mongoDB and need to achieve this task.
I have a collection containing documents similar to the sample below.
{
"_id" : 1900123,
"name" : "AAAAA BBBB",
"scores" : [
{
"type" : "exam",
"score" : 44.51211101958831
},
{
"type" : "quiz",
"score" : 0.6578497966368002
},
{
"type" : "projectwork",
"score" : 93.36341655949683
},
{
"type" : "projectwork",
"score" : 49.43132782777443
}
]
}
I am trying to read this collection in a python script. I am unable to retrieve the score from the sub document
cursor = students.find()
for doc in cursor:
score1=doc["scores.2.score"];
print("score1=",score1);
I am trying to find the lowest score for project work for each student, but i am unable to retrieve the score using index "scores.2.score".
Need some help to understand the retrieval method.