Skip to content

Instantly share code, notes, and snippets.

@hatak
Last active August 29, 2015 14:23
Show Gist options
  • Save hatak/11152c53c47b3116c55b to your computer and use it in GitHub Desktop.
Save hatak/11152c53c47b3116c55b to your computer and use it in GitHub Desktop.
Generate presentation order
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import random
import csv
group_list = []
members = {}
def main(args):
with open(sys.argv[1]) as csv_file:
reader = csv.reader(csv_file, quotechar='"')
for row in reader:
if not row[1] in members:
members[row[1]] = []
members[row[1]].append(row[0])
group_order = random_sorted(members.keys())
for group in group_order:
presenter = random_sorted(members[group])[0]
print('%s : %s' % (group, presenter))
def random_sorted(original_list):
return sorted(original_list, key=lambda *args: random.random())
if __name__ == '__main__':
if len(sys.argv) == 2:
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment