Last active
September 14, 2016 15:12
-
-
Save kylebshr/3203653a032fd0a2ef893465fb6e7b55 to your computer and use it in GitHub Desktop.
Volhacks Attendee Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
import subprocess | |
NON_UTK_TICKET = 'Student Registration for non-UTK Students' | |
UTK_TICKET = 'Student Registration for UTK Students' | |
MENTOR_TICKET = 'Mentor Registration' | |
ORGANIZER_TICKET = 'Organizer' | |
PERCENT_NON_UTK = 0.45 | |
PERCENT_UTK = 0.7 | |
PERCENT_MENTOR = 1 | |
PERCENT_ORGANIZER = 1 | |
process_csv = 0 | |
try: | |
process_file = file(str(raw_input('Please enter the name of the CSV file: ')), 'r') | |
process_csv = list(csv.reader(process_file)) | |
except: | |
print('Error opening file') | |
sys.exit() | |
if process_csv[0][5] != 'Ticket Type' or process_csv[0][10] != 'T-Shirt Size' or process_csv[0][4] != 'Email': | |
print('Invalid CSV') | |
sys.exit() | |
emails = int(raw_input('Enter 0 to copy hacker emails, or 1 for attendee info/stats: ')) | |
# EMAILS | |
if emails == 0: | |
emails = '' | |
for row in process_csv: | |
email = row[4] | |
ticket_type = row[5] | |
if ticket_type == NON_UTK_TICKET or ticket_type == UTK_TICKET: | |
emails += email + '\n' | |
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE) | |
p.stdin.write(emails) | |
p.stdin.close() | |
retcode = p.wait() | |
print('\nCopied emails to clipboard\n') | |
sys.exit() | |
# ATTENDEE INFO | |
estimated_attendee_count = 0.0 | |
real_non_utk_count = 0.0 | |
real_utk_count = 0.0 | |
real_mentor_count = 0.0 | |
real_organizer_count = 0.0 | |
for row in process_csv: | |
ticket_type = row[5] | |
if ticket_type == NON_UTK_TICKET: | |
real_non_utk_count += 1 | |
elif ticket_type == UTK_TICKET: | |
real_utk_count += 1 | |
elif ticket_type == MENTOR_TICKET: | |
real_mentor_count += 1 | |
elif ticket_type == ORGANIZER_TICKET: | |
real_organizer_count += 1 | |
estimated_non_utk_count = real_non_utk_count * PERCENT_NON_UTK | |
estimated_utk_count = real_utk_count * PERCENT_UTK | |
estimated_mentor_count = real_mentor_count * PERCENT_MENTOR | |
estimated_organizer_count = real_organizer_count * PERCENT_ORGANIZER | |
estimated_attendee_count = estimated_non_utk_count + estimated_utk_count + estimated_mentor_count + estimated_organizer_count | |
print('\n\nAttendee Information\n-------------------') | |
print('Expected non-UTK hackers: ' + str(estimated_non_utk_count)) | |
print('Expected UTK hackers: ' + str(estimated_utk_count)) | |
print('Expected mentors: ' + str(estimated_mentor_count)) | |
print('Expected organizers: ' + str(estimated_organizer_count)) | |
print('Total expected attendees: ' + str(estimated_attendee_count)) | |
# SHIRTS | |
SMALL_SHIRT_BUFFER = 10 | |
LARGE_SHIRT_BUFFER = 20 | |
XSMALL = 'XS' | |
SMALL = 'S' | |
MEDIUM = 'M' | |
LARGE = 'L' | |
XLARGE = 'XL' | |
XXLARGE = '2XL' | |
shirt_count = 0.0 | |
xsmall_count = 0.0 | |
small_count = 0.0 | |
medium_count = 0.0 | |
large_count = 0.0 | |
xlarge_count = 0.0 | |
xxlarge_count = 0.0 | |
for row in process_csv: | |
shirt_size = row[10] | |
if shirt_size != '': | |
shirt_count +=1 | |
if shirt_size == XSMALL: | |
xsmall_count += 1 | |
elif shirt_size == SMALL: | |
small_count += 1 | |
elif shirt_size == MEDIUM: | |
medium_count += 1 | |
elif shirt_size == LARGE: | |
large_count += 1 | |
elif shirt_size == XLARGE: | |
xlarge_count += 1 | |
elif shirt_size == XXLARGE: | |
xxlarge_count += 1 | |
percent_xsmall = xsmall_count / shirt_count | |
percent_small = small_count / shirt_count | |
percent_medium = medium_count / shirt_count | |
percent_large = large_count / shirt_count | |
percent_xlarge = xlarge_count / shirt_count | |
percent_xxlarge = xxlarge_count / shirt_count | |
# print('Percent xsmall: ' + str(percent_xsmall)) | |
# print('Percent small: ' + str(percent_small)) | |
# print('Percent medium: ' + str(percent_medium)) | |
# print('Percent large: ' + str(percent_large)) | |
# print('Percent xlarge: ' + str(percent_xlarge)) | |
# print('Percent xxlarge: ' + str(percent_xxlarge)) | |
print('\n\nShirt Information\n-------------------') | |
print('XS Order: ' + str((percent_xsmall * estimated_attendee_count) + SMALL_SHIRT_BUFFER)) | |
print('S Order: ' + str((percent_small * estimated_attendee_count) + SMALL_SHIRT_BUFFER)) | |
print('M Order: ' + str((percent_medium * estimated_attendee_count) + LARGE_SHIRT_BUFFER)) | |
print('L Order: ' + str((percent_large * estimated_attendee_count) + LARGE_SHIRT_BUFFER)) | |
print('XL Order: ' + str((percent_xlarge * estimated_attendee_count) + SMALL_SHIRT_BUFFER)) | |
print('XXL Order: ' + str((percent_xxlarge * estimated_attendee_count) + SMALL_SHIRT_BUFFER)) | |
# FOOD | |
ROW_TITLE = 'Do you have any dietary restrictions?' | |
NO_FOOD = 'No Restrictions' | |
VEG_FOOD = 'Vegetarian' | |
print('\n\nFood Information\n-------------------') | |
for row in process_csv: | |
food_type = row[14] | |
email = row[4] | |
if not (food_type == '' or food_type == NO_FOOD or food_type == VEG_FOOD or food_type == ROW_TITLE): | |
print('Food Type: {:35} Email: {}'.format(food_type, email)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment