Guest User

Untitled

a guest
Mar 26th, 2017
73
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.  
  7. client = pymongo.MongoClient()
  8. db = client.enron
  9. mbox = db.mbox
  10.  
  11. //Get the recipient lists for each message
  12.  
  13. recipients_per_message = db.mbox.aggregate([
  14. {"$match" : {"From" : re.compile(r".*{0}.*".format(FROM), re.IGNORECASE)}},
  15. {"$project" : {"From" : 1, "To" : 1} },
  16. {"$group" : {"_id" : "$From", "recipients" : {"$addToSet" : "$To" } } }
  17. ])['result'][0]['recipients']
Advertisement
Add Comment
Please, Sign In to add comment