Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Created December 1, 2015 18:58
Show Gist options
  • Save jpotts18/64acd60e11355fe28292 to your computer and use it in GitHub Desktop.
Save jpotts18/64acd60e11355fe28292 to your computer and use it in GitHub Desktop.
import uuid, random, json
# json.dumps(x, indent=4)
product_range = range(100000,110000)
num_recs_per_type = 20
num_users = 500000
user_ids = [ str(uuid.uuid1()) for _ in range(num_users) ]
rec_types = ['by_x','by_y','by_z']
user_recs = []
for _ in xrange(num_users):
user_recs.append(
{ "user_guid": str(uuid.uuid1()),
"recommendations" : { r :random.sample(product_range, num_recs_per_type) for r in rec_types }})
with open('user-recs-' + str(num_users) + '-users.json', 'wb') as f:
f.write(json.dumps(user_recs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment