title: mongodb insertion shows 'strings in documents must be valid UTF-8'
body: <p>this is my code</p>
  
  <pre><code>        for code, data in dict_data.items(): 
  
              try:
                  collection2.insert({'_id':code,'data':data})
  
              except Exception as e:
                  print code,'&gt;&gt;&gt;&gt;&gt;&gt;&gt;', str(e)
                  sys.exit()
  </code></pre>
  
  <p>it exited with</p>
  
  <pre><code>         524715 &gt;&gt;&gt;&gt;&gt;&gt;&gt; strings in documents must be valid UTF-8
  </code></pre>
  
  <p>I could find out the error only by the try catch method. dict_data is a large dictionary which contains calculated values from other collection.</p>
  
  <p>how can i fix this?</p>
  
  <p>thanks</p>