Commits

Farhan Ahmed  committed 0c639d7

Initial checkin

  • Participants

Comments (0)

Files changed (3)

File .coffee.py.swp

Binary file added.
+import csv
+import os
+import sys
+
+MAX_MATCH = 2
+
+if len(sys.argv) != 2:
+    print "Please provide the name of the CSV file"
+else:
+    # Read the file name to process
+    f = sys.argv[1]
+    reader = csv.reader(open(f,'r'), delimiter=',')
+    
+    # List of participants for each year
+    c2013 = []
+    c2014 = []
+    
+    # Read and parse the CSV file
+    for row in reader:
+
+        # This must be the header
+        if '2013' not in row[4] and '2014' not in row[4]:
+            continue
+
+        # Initialize the object and fill in the details from
+        # the CSV file
+        o = {}
+        o['name'] = row[1] + ' ' + row[2]
+        o['email'] = row[3]
+
+        # 'Roles' and 'Geographies' are lists separated by commas
+        o['roles'] = row[5].split(',')
+        o['geo'] = row[5].split(',')
+      
+        # The 'count' field counts the number of matches (either way)
+        o['count'] = 0
+
+        # Append this entry into the appropriate list
+        if '2013' in row[4]:
+            c2013.append(o)
+        else:
+            c2014.append(o)
+    
+    # The core matching algorithm. Basically we traverse the list of class of
+    # 2013 students and for each one of them, figure out a 'matching score' for
+    # each participant in the class of 2014. The higher the score, the better the
+    # match. If both geography and role preferences matches, it is given a higher
+    # preference
+
+    matches = []
+
+    for item in c2013:
+
+        # Traverse over the list of class of 2014
+        for s in c2014:
+
+            # The initial scores (role count = geo count = 0, m = 1 iff rc,gc>0)
+            rc = 0
+            gc = 0
+            m = 0
+
+            # Let's see if the role preferences match. If so, increment the count
+            for rl in item['roles']:
+                if rl in s['roles']:
+                    rc = rc + 1
+
+            # Let's see if the geography preferences match ..
+            for gl in item['geo']:
+                if gl in s['geo']:
+                    gc = gc + 1
+            
+            # If both the role and geographies match, note this
+            if gc > 0 and rc > 0:
+                m = 1
+            
+            # Create an entry for this match and append it to the list of matches
+            entry = {}
+            entry['2013'] = item
+            entry['p'] = rc + gc
+            entry['m'] = m
+            entry['2014'] = s
+        
+            matches.append(entry)
+        
+    a = sorted(matches, key=lambda d: (-d['m'], -d['p']))
+
+    print "\nSuccessful matches"
+    print "------------------"
+
+    for item in a:
+        
+        if (item['p'] > 0):
+
+            # Don't print the match if either of them matched students have met their match
+            # criteria
+            if item['2013']['count'] == MAX_MATCH or item['2014']['count'] == MAX_MATCH:
+                continue
+
+            print item['2013']['name'] + " (" + item['2013']['email'] + ")\t" \
+                    + item['2014']['name'] + " (" + item['2014']['email'] + ")\t" + str(item['m']) + "\t" + str(item['p'])
+
+            # Since this was a successful match, increment their match counts
+            item['2013']['count'] = item['2013']['count'] + 1
+            item['2014']['count'] = item['2014']['count'] + 1
+
+            c2013 = [a for a in c2013 if a is not item['2013']]
+            c2014 = [a for a in c2014 if a is not item['2014']]
+
+    print "\nUnsuccessful matches"
+    print "--------------------"
+
+    print "\nClass of 2013"
+    print "-------------"
+
+    for item in c2013:
+
+        # Print the unmatched participants
+        print item['name'] + " " + item['email']
+
+    print "\nClass of 2014"
+    print "-------------"
+
+    for item in c2014:
+
+        # Print the unmatched participants
+        print item['name'] + " " + item['email']
+Timestamp,Your first name,Your last name,Your Booth email address (with the @chicagobooth.edu suffix),Your class year,What industries and functions are you interested in talking about with another student?,Which geographies are you interested in talking about with another student?
+8/10/2012 16:44:40,Test2014-1,A,test2014-1@chicagobooth.edu,1st year (Class of 2014),Advertising/Communications ,Mid-Atlantic - Washington D.C. Metro 
+8/10/2012 16:45:05,Test2014-2,A,test2014-2@chicagobooth.edu,1st year (Class of 2014),"Advertising/Communications , Agribusiness ",Mid-Atlantic - Other 
+8/10/2012 16:45:20,Test2014-3,A,test2014-3@chicagobooth.edu,1st year (Class of 2014),Arts/Media/Entertainment ,Mid-Atlantic - Other 
+8/10/2012 16:45:40,Test2014-4,A,test2014-4@chicagobooth.edu,1st year (Class of 2014),Chemicals/Plastics ,"Mid-Atlantic - Washington D.C. Metro , Mid-Atlantic - Other , Midwest - Chicago Metro , Midwest - Minneapolis/St. Paul Metro , Midwest - Other , Northeast - Boston Metro Area , Northeast - New York City Metro , Northeast - Other "
+8/10/2012 16:46:01,Test2014-5,A,test2014-4@chicagobooth.edu,1st year (Class of 2014),"Chemicals/Plastics , Financial Services - Investment Banking/Brokerage , Financial Services - Sales & Trading , Financial Services - Venture Capital ",Africa 
+8/10/2012 17:14:25,Test2013-1,B,test2013-1@chicagobooth.edu,2nd year (Class of 2013),"Advertising/Communications , Agribusiness ",Mid-Atlantic - Washington D.C. Metro 
+8/10/2012 17:14:41,Test2013-2,B,test2013-2@chicagobooth.edu,2nd year (Class of 2013),"Advertising/Communications , Chemicals/Plastics ","Mid-Atlantic - Washington D.C. Metro , Northeast - Boston Metro Area , Northeast - New York City Metro "
+8/10/2012 17:14:59,Test2013-3,B,test2013-3@chicagobooth.edu,2nd year (Class of 2013),"Chemicals/Plastics , Consulting ","West - Los Angeles Metro , Other U.S. Possessions and Territories "
+8/10/2012 17:15:16,Test2013-4,B,test2013-4@chicagobooth.edu,2nd year (Class of 2013),"Agribusiness , Corporate Roles - Strategic Planning , Energy ","Midwest - Chicago Metro , Midwest - Minneapolis/St. Paul Metro , West - Los Angeles Metro , Other U.S. Possessions and Territories "
+8/10/2012 17:15:40,Test2013-5,B,test2013-5@chicagobooth.edu,2nd year (Class of 2013),Government/Nonprofit ,Europe - Other