Skip to content

Instantly share code, notes, and snippets.

@jdherman
Created December 9, 2015 18:24

Revisions

  1. jdherman created this gist Dec 9, 2015.
    29 changes: 29 additions & 0 deletions exstatic.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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])