I'm Vice Wing Commander at the Air Force Detachment I go to here at college. One responsibility of my job is taking attendance. Within the wing there are four squadrons. Each squadron turns in attendance every week and I have to transfer the attendance recorded to an attendance tracker written in an Excel worksheet. As you can imagine, this is very tedious work. Since I know some programming (I'm a senior comp sci major), I decided to write a python script that would automatically transfer the attendance. I'm using xlrd/xlwt/xlutils but I'm running into some issues. Basically what I'm trying to do is create key value pairs using the cadet's name and their attendance status taken from one worksheet, and export the values to the attendance tracker. Maybe I'm going about this wrong, but it's not working out so well. So far, the only thing I've been able to do is import the attendance from one file into key value pairs within the program. The issues come when I try to export these values. I've posted one question here which was resolved and an unanswered one here relating to my little project. Below is the code I have so far:
from xlrd import open_workbook
wb = open_workbook('week1/AFROTC SP13 Eagles Sqaudron Weekly Attendance.xls')
LLab = {}
PT = {}
for s in wb.sheets():
if s.name == "LLab":
for row in range(s.nrows):
values = []
for col in range(s.ncols):
values.append(s.cell(row,col).value)
if values[1] == "0" or values[1] == "1":
LLab[values[0]]=int(values[1])
elif s.name == "PT":
for row in range(s.nrows):
values = []
for col in range(s.ncols):
if s.cell(row,col).value != "PT #1" and s.cell(row,col).value != "PT #2":
values.append(s.cell(row,col).value)
if len(values) == 3:
PT[values[0]]=[int(values[1]), int(values[2])]
print "LLab"
for key in LLab:
print key,
print LLab[key]
print
print
print "PT"
for key in PT:
print key,
print PT[key][0],
print PT[key][1]
It is only importing attendance from one file for now (there are four, one for each squadron).