Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import json
  2. import pymongo
  3. from bson import json_util
  4. import re
  5.  
  6. FROM = "kenneth.lay@enron.com"
  7.  
  8. client = pymongo.MongoClient()
  9. db = client.enron
  10. mbox = db.mbox
  11.  
  12. //Get the recipient lists for each message
  13.  
  14. recipients_per_message = db.mbox.aggregate([
  15. {"$match" : {"From" : re.compile(r".*{0}.*".format(FROM), re.IGNORECASE)}},
  16. {"$project" : {"From" : 1, "To" : 1} },
  17. {"$group" : {"_id" : "$From", "recipients" : {"$addToSet" : "$To" } } }
  18. ])['result'][0]['recipients']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement