Skip to content

Instantly share code, notes, and snippets.

@phil-lopreiato
Created April 24, 2015 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phil-lopreiato/5b437324aec4d6d6b2aa to your computer and use it in GitHub Desktop.
Save phil-lopreiato/5b437324aec4d6d6b2aa to your computer and use it in GitHub Desktop.
Hacky 2015cmp Results Script
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