Skip to content

Instantly share code, notes, and snippets.

@prehistoricpenguin
Created January 5, 2013 12:43
Show Gist options
  • Select an option

  • Save prehistoricpenguin/4461404 to your computer and use it in GitHub Desktop.

Select an option

Save prehistoricpenguin/4461404 to your computer and use it in GitHub Desktop.
a script which joins two .xls files,then make statistic
import xlrd
nameBook = xlrd.open_workbook("/home/chm/Documents/namesheet.xls")
markBook = xlrd.open_workbook("/home/chm/Documents/mark.xls")
nameSheet = nameBook.sheet_by_index(0)
markSheet = markBook.sheet_by_index(0)
fullmark = 0
aboveninety = 0
aboveeighty = 0
abovesixty = 0
belowsixty = 0
for rx in range(markSheet.nrows):
for ry in range(nameSheet.nrows):
studentId=(int)(markSheet.cell_value(rx,2))
if (studentId/1000000000 == 1023) and studentId%100 == nameSheet.cell_value(ry,0):
mark = markSheet.cell_value(rx,3)
print nameSheet.cell_value(ry,1),mark
if mark == 100:
fullmark +=1
elif mark >=90:
aboveninety +=1
elif mark >=80:
aboveeighty +=1
elif mark >=60:
abovesixty += 1
else:
belowsixty += 1
print "fullmarks:\t",fullmark
print "90~100:\t\t",aboveninety
print "80~90:\t\t",aboveeighty
print "60~80:\t\t",abovesixty
print "0~60:\t\t",belowsixty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment