Created
April 24, 2015 00:13
-
-
Save phil-lopreiato/5b437324aec4d6d6b2aa to your computer and use it in GitHub Desktop.
Hacky 2015cmp Results Script
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 xlrd | |
import csv | |
def clean(cell): | |
bad_chars = ['(', ')', '*'] | |
val = str(cell.value) | |
val = val.translate(None, ''.join(bad_chars)) | |
return int(float(val)) | |
workbook = xlrd.open_workbook("results.xlsx") | |
sheet_names = workbook.sheet_names() | |
for name in sheet_names: | |
print name | |
sheet = workbook.sheet_by_name(name) | |
with open("thu-lunch/{}.csv".format(name), 'wb') as csvout: | |
writer = csv.writer(csvout, delimiter=',') | |
for row in range(1, sheet.nrows): | |
line = sheet.row(row) | |
if line[8].ctype == 0 or line[9].ctype == 0: | |
continue | |
out = ["qm{}".format(int(line[0].value)), clean(line[2]), clean(line[3]), clean(line[4]), clean(line[5]), clean(line[6]), clean(line[7]), int(line[8].value), int(line[9].value)] | |
writer.writerow(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment