Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import pymongo
- from bson import json_util
- import re
- FROM = "kenneth.lay@enron.com"
- client = pymongo.MongoClient()
- db = client.enron
- mbox = db.mbox
- //Get the recipient lists for each message
- recipients_per_message = db.mbox.aggregate([
- {"$match" : {"From" : re.compile(r".*{0}.*".format(FROM), re.IGNORECASE)}},
- {"$project" : {"From" : 1, "To" : 1} },
- {"$group" : {"_id" : "$From", "recipients" : {"$addToSet" : "$To" } } }
- ])['result'][0]['recipients']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement