Skip to content

Instantly share code, notes, and snippets.

@danared danared/randomdocs
Created Feb 12, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.