title: Querying mongoDb using pymongo with variable values
body: <p>Consider the have the following collection:</p>
  
  <pre><code>db.collection.insert({id:1, value:1})
  db.collection.insert({id:2, value:2})
  db.collection.insert({id:3, value:3})
  </code></pre>
  
  <p>Now, I have a file which has a list of ids. I can read the file and store the id in a variable. How do I now query the collection to get the details  of that particular id:</p>
  
  <pre><code>f=open("file.txt")
  for line in f:
    idTemp=line.strip()
    db.collection.find_one({"id":idTemp}) #This does not work
  </code></pre>