| 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