Skip to content

Instantly share code, notes, and snippets.

@phette23
Last active July 17, 2017 20:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save phette23/4e8bfa6da11532563d71 to your computer and use it in GitHub Desktop.
script to take an Informer report of degree code totals & map them into our human-friendly major terms
#!/usr/bin/env python
# usage:
# sum-majors.py "LI - Library students per term.csv" > "YEAR majors total.csv"
import csv
import fileinput
import sys
majors = csv.DictReader(fileinput.input(mode='rb'))
# mapping of degree codes to majors will change over time
# as will the "totals" dict below listing our majors
map = {
'ANIMA.BFA': 'Animation',
'ARCHT.BARC': 'Architecture',
'CERAM.BFA': 'Ceramics',
'COMAR.BFA': 'Community Arts',
'COMIC.MFA': 'MFA Comics',
'CURPR.MA': 'MA Curatorial',
# commented out programs are non-degree, not counted here
# 'DD2ST': '',
'DESGN.MFA': 'MFA Design',
'DESST.MBA': 'MBA Design',
# 'DVCCP': '',
# 'DVCFA': '',
# 'DVCWR': '',
'FASHN.BFA': 'Fashion',
'FILMG.MFA': 'MFA Fine Arts',
'FILMS.BFA': 'Film/Media',
'FINAR.MFA': 'MFA Fine Arts',
'FRNTR.BFA': 'Wood/Furniture',
'GLASS.BFA': 'Glass',
'GRAPH.BFA': 'Graphic Design',
'GRAPH.MFA': 'MFA Design',
'ILLUS.BFA': 'Illustration',
'INACT.MFA': 'MFA Design',
'INDIV.BFA': 'Individualized',
'INDUS.BFA': 'Industrial Design',
'INDUS.MFA': 'MFA Design',
'INTER.BFA': 'Interior Design',
'IXDSN.BFA': 'Interaction Design',
'MAAD1.MAAD': 'MA Architecture',
'MARCH.MARC': 'MA Architecture',
'MARC2.MARC': 'MA Architecture',
'MARC3.MARC': 'MA Architecture',
'METAL.BFA': 'Jewelry/Metal Arts',
# 'NODEG.UG': '',
'PHOTO.BFA': 'Photography',
'PNTDR.BFA': 'Painting/Drawing',
'PRINT.BFA': 'Printmaking',
'SCULP.BFA': 'Sculpture',
'SFMBA.MBA': 'MBA Strategic Finance',
'TEXTL.BFA': 'Textiles',
'UNDEC.BFA': 'Undeclared',
'VISCR.MA': 'MA Visual Criticism',
'VISST.BA': 'Visual Studies',
'WRITE.MFA': 'MFA Writing',
'WRLIT.BA': 'Writing & Literature',
}
totals = {
# Design + Architecture divisions
'Architecture': 0,
'Fashion': 0,
'Graphic Design': 0,
'Illustration': 0,
'Industrial Design': 0,
'Interior Design': 0,
'Interaction Design': 0,
'Wood/Furniture': 0,
'MA Architecture': 0,
'MFA Design': 0,
'MBA Design': 0,
'MBA Strategic Finance': 0,
# Fine Arts division
'Animation': 0,
'Ceramics': 0,
'Community Arts': 0,
'Film/Media': 0,
'Glass': 0,
'Individualized': 0,
'Jewelry/Metal Arts': 0,
'Photography': 0,
'Painting/Drawing': 0,
'Printmaking': 0,
'Sculpture': 0,
'Textiles': 0,
'MFA Fine Arts': 0,
# Humanities & Sciences Division, also encompasses miscellany
'Undeclared': 0,
'Visual Studies': 0,
'Writing & Literature': 0,
'MFA Comics': 0,
'MA Curatorial': 0,
'MA Visual Criticism': 0,
'MFA Writing': 0,
}
for major in majors:
program = map.get(major['Active Programs'])
if program in totals:
totals[program] += int(major['Count'])
outcsv = csv.DictWriter(sys.stdout, ['Program', 'Students'])
outcsv.writeheader()
for total in sorted(totals):
outcsv.writerow({'Program': total, 'Students': totals[total]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment