from mongoOperations import getUsers, getUsersFromUserFriends, getUsersFromUserFriendsAsc from userExtract import extractFriends from locationEstimation import getUserLocation import ujson users = getUsersFromUserFriendsAsc(1) res = [] usersCount = users.count() for user in users: data = {} userId = user['user_id'] data = getUserLocation(userId) data["user_id"] = userId data["friends"] = [] i = 0 for f in user["friends"]: if f != userId: friend = {} friend = getUserLocation(f) # friend["user_id"] = f # print friend data["friends"].append(friend) res.append(data) # from pymongo import MongoClient # # client = MongoClient() # # db = client['yelp'] # # db.user_test.insert_many(res)
users = getUsersFromUserFriends(500) data = {} # friends = {} friends = [] i = 0 # print "STATUS:" usersCount = users.count() print usersCount for user in users: friend = {} i += 1 print "Processing User", i,"of", usersCount # print "Percentage Complete: ", float(i/usersCount) * 100,"%" userId = user['user_id'] data[userId] = getUserLocation(userId) data[userId]["user_id"] = userId data[userId]["friends"] = user["friends"] friends.append(data[userId]) # from pymongo import MongoClient # # client = MongoClient() # # db = client['yelp'] # # db.user_test.insert_many(friends) with open('../../static/json/user_location_data.json', 'w+') as outfile: json.dump(friends, outfile)
users = getUsersFromUserFriends(500) data = {} # friends = {} friends = [] i = 0 # print "STATUS:" usersCount = users.count() print usersCount for user in users: friend = {} i += 1 print "Processing User", i, "of", usersCount # print "Percentage Complete: ", float(i/usersCount) * 100,"%" userId = user['user_id'] data[userId] = getUserLocation(userId) data[userId]["user_id"] = userId data[userId]["friends"] = user["friends"] friends.append(data[userId]) # from pymongo import MongoClient # # client = MongoClient() # # db = client['yelp'] # # db.user_test.insert_many(friends) with open('../../static/json/user_location_data.json', 'w+') as outfile: json.dump(friends, outfile)