Created
August 28, 2014 15:21
-
-
Save PBarmby/7bc6dec91db4dc9f3c62 to your computer and use it in GitHub Desktop.
Class list viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
show_student_pix: | |
Uses a Western University class list file (typically named .rcl | |
but really .csv) and the accompanying set of jpg student ID | |
pictures to display a few random pictures/names at a time. | |
Designed for use in IPython notebook. | |
2014-08-28, P. Barmby | |
License: CC-BY | |
Usage: | |
classlist = pandas.read_csv('ASTRONOM9099ALEC001.rcl',usecols=[8,9,10,12,13],names=['ID', 'Last','First','Prog','email']) | |
show_student_pix(classlist,3) | |
""" | |
import pandas | |
import numpy.random as npr | |
import os | |
from IPython.display import Image, display | |
def show_student_pix(classlist, nstd): | |
class_size = len(classlist) | |
for j in range(0,nstd): | |
rands=npr.randint(0,class_size) | |
picfile = 'P%9d.jpg'% classlist.ix[rands]['ID'] | |
if os.path.isfile(picfile): | |
i = Image(filename=picfile) | |
display(i) | |
print classlist.ix[rands]['First'],classlist.ix[rands]['Last'] | |
return | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment