Skip to content

Instantly share code, notes, and snippets.

@jdherman
Created December 9, 2015 18:24
Show Gist options
  • Save jdherman/c693375c80217e8321d8 to your computer and use it in GitHub Desktop.
Save jdherman/c693375c80217e8321d8 to your computer and use it in GitHub Desktop.
exstatic syllabi keyword analysis
import glob
kw = ['climate', 'decision theory', 'dynamic', 'economics', 'game theory', 'heuristic', 'hydrology',
'integer', 'linear', 'model', 'nonlinear', 'policy', 'probability', 'statistics',
'stochastic','quality', 'simulation', 'optimization']
files = glob.glob('*.txt')
courses_including = {}
avg_count = {}
for k in kw:
courses_including[k] = 0
avg_count[k] = 0
for f in files:
total = 0
for line in open(f):
if k in line.lower():
if total == 0:
courses_including[k] += 1
total += 1
avg_count[k] += total
avg_count[k] /= courses_including[k]
for k,v in courses_including.iteritems():
print '%s,%d,%d' % (k,v,avg_count[k])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment