Skip to content

Instantly share code, notes, and snippets.

@rafkhan
Last active December 15, 2015 18:59
Show Gist options
  • Save rafkhan/5308248 to your computer and use it in GitHub Desktop.
Save rafkhan/5308248 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import sys
from xlrd import open_workbook
wb = open_workbook('EligibleUSmemberForTAworkshop.xlsx')
values = []
for s in wb.sheets():
for row in range(s.nrows):
values.append(s.cell(row, int(sys.argv[1])).value)
values.sort()
r = range
matrix = map(lambda x: map(lambda x: map(lambda x: 0, r(10)), r(10)), r(10)) #BAD RAF
values = filter(lambda x: x != "", values)
for v in values:
try:
i = map(int, v[:3])
matrix[i[0]][i[1]][i[2]] += 1
except Exception:
pass
f = open('output.md', 'w')
rdc = lambda(l): reduce(lambda x, y: x + y, l)
for ai, av in enumerate(matrix):
f.write(str(ai) +": "+ str(rdc(map(rdc, av))) + "\r\n")
for bi, bv in enumerate(av):
f.write(" " + str(ai) + str(bi) + ": " + str(rdc(bv)) + "\r\n")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment