# -*- coding: utf-8 -*-
import json, io, re
r = json.load(io.open("_density_report.json", encoding="utf-8"))
OK = ["cornell", "ucsd", "notre", "geo", "uchicago", "col", "jhu", "up", "northwestern", "duke",
      "emory", "uva", "wustl", "mcg", "brown", "rice", "vanderbilt", "ubc", "ut", "dartmouth",
      "yale", "cmu", "princeton", "gatech", "umich", "ucla", "harvard", "stanford", "berkeley", "usc",
      "caltech", "mit", "illinois", "nyu", "unc", "uw"]
POP = ["cs", "ee", "fin", "econ", "ba", "ds", "stat", "me", "bio", "mgmt", "mgt", "mba", "ms"]
rows = [x for x in r["rows"] if x["grade"] != "A"]
def key(x):
    return (-x["score"], x["chars"] if False else 0)
out = []
for x in rows:
    s = x.get("s", "")
    if any(s.startswith(p) for p in ["cornell", "ucsd", "notre", "geo", "uchicago", "col", "jhu", "up", "northwestern", "emory", "uva", "wustl", "mcg", "brown", "rice", "vanderbilt", "ubc", "ut", "dartmouth", "cmu", "princeton", "gatech", "duke", "yale", "ucla", "umich"]):
        if x["score"] >= 6:
            out.append(x)
out.sort(key=lambda x: -x["score"])
for x in out[:60]:
    m = x["m"]
    print("%2d %s %-28s cards=%d chars=%d codes=%d money=%d dates=%d ext=%d | %s" % (
        x["score"], x["grade"], x["id"], m["cards"], m["chars"], m["codes"], m["money"], m["dates"], m["ext_links"], x["n"][:34]))
print("TOTAL", len(out))
