Skip to content

Instantly share code, notes, and snippets.

@danared
Created February 12, 2016 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danared/e8192e18106ec43cfc64 to your computer and use it in GitHub Desktop.
Save danared/e8192e18106ec43cfc64 to your computer and use it in GitHub Desktop.
def load_data(collection, n=100):
#let's skip some elements
skiplist = [10, 12, 231 , 2 , 4]
for i,d in load_data_file(n):
d['i'] = i
if i in skiplist:
continue
collection.insert( d )
load_data(collection, 100)
distinct = collection.distinct('i')
ivalue = random.sample(distinct, 1)
winner = collection.find_one({ 'i': ivalue })
print "AND THE WINNER IS ..... " + winner['name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment