I have a db configured in mongo, which I handle with pymongo.
I would like to be able to pull a small set of fields into a list of dictionaries. So, something like what I get in the mongo shell as I type ...
db.find({},{"variable1_of_interest":1, "variable2_of_interest":1}).limit(2).pretty()
I need a python statement like:
x = db.find({},{"variable1_of_interest":1, "variable2_of_interest":1})
where x is some structure of the array, and not the cursor --- that is, instead of iteration, for example:
data = [] x = db.find({},{"variable1_of_interest":1, "variable2_of_interest":1}) for i in x: data.append(x)
Is it possible that I can use MapReduce to bring it to a single line? Something like
db.find({},{"variable1_of_interest":1, "variable2_of_interest":1}).map_reduce(mapper, reducer, "data")
I am going to output this dataset in R for some analysis, but I would like to concentrate IO on Python.
mongodb pymongo
Mittenchops
source share