Created
February 16, 2018 15:42
-
-
Save theriley106/049cedd8f1c964aac472eef18ab243d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
# sys.setdefaultencoding() does not exist, here! | |
reload(sys) # Reload does the trick! | |
sys.setdefaultencoding('UTF8') | |
import json | |
import glob | |
import traceback | |
DB = {"Total": 0} | |
finalList = {} | |
listF = [] | |
listOfSchools = open("listOfSchools.txt").read().split("\n") | |
for val in listOfSchools: | |
schoolName = val.partition("|")[0].strip() | |
for name in val.split("|"): | |
if len(name) > 1: | |
finalList[name.lower().strip()] = schoolName.lower().strip() | |
def getCollege(text): | |
info = [] | |
# input string of text and it returns colleges inside | |
for college in finalList.keys(): | |
if college.lower() in text.lower(): | |
#print str(text.split(" ")).lower() | |
for i in range(text.lower().count(college.lower())): | |
info.append(finalList[college]) | |
return info | |
def ldJsonToList(jsonFile): | |
DATA = [] | |
for var in open(glob.glob(jsonFile)[0], 'rb').read().split('\n'): | |
try: | |
DATA.append(json.loads(var)) | |
except: | |
pass | |
return DATA | |
listOfAllSchoolNames = ldJsonToList("SchoolList.json") | |
for i, comment in enumerate(listOfAllSchoolNames): | |
try: | |
collegeInText = getCollege(comment['body']) | |
for val in collegeInText: | |
listF.append(val) | |
except Exception as exp: | |
traceback.print_exc() | |
pass | |
DATA = {} | |
for val in list(set(listF)): | |
DATA[val] = listF.count(val) | |
print DATA |
This file contains hidden or 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
Princeton University | princeton | |
Harvard University | harvard | |
University of Chicago | uchicago | uc hicago | |
Yale University | yale | |
Columbia University | columbia | |
Massachusetts Institute of Technology | mit | m.i.t | |
Stanford University | stanford | "stanford" | |
University of Pennsylvania | upenn | wharton | u penn | |
Duke University | duke | |
California Institute of Technology | caltech | cal tech | |
Dartmouth College | dartmouth | |
Johns Hopkins University | john hopkins | jhu | johns hopkins | |
Northwestern University | northwestern | |
Brown University | brown | |
Cornell University | cornell | |
Rice University | rice | |
Vanderbilt University | vanderbilt | |
University of Notre Dame | notre dame | |
Washington University in St. Louis | wustl | w.u.s.t.l | |
Georgetown University | georgetown | |
Emory University | emory | |
University of California--Berkeley | uc berkeley | berkeley | ucb | |
University of California--Los Angeles | ucla | |
University of Southern California | usc | |
Carnegie Mellon University | cmu | carnegie mellon | carnegie melon | |
University of Virginia | uva | u.v.a | |
Wake Forest University | wake forest | |
Tufts University | tufts | |
New York University | nyu | n.y.u | |
University of North Carolina--Chapel Hill | unc chapel hill | chapel hill | uncch | |
Boston College | bc | |
College of William and Mary | william and mary | william & mary | w and m | w&m | w & m | |
Brandeis University | brandeis | |
Georgia Institute of Technology | gatech | gtech | georgia tech | ga tech | |
University of Rochester | rochester | |
Boston University | bu | |
Case Western Reserve University | case western | cwru | |
University of California--Santa Barbara | ucsb | u.c.s.b | uc santa barbara | |
Northeastern University | northeastern | |
Tulane University | tulane | |
Rensselaer Polytechnic Institute | rpi | rensselaer | r.p.i | |
University of California--Irvine | uc irvine | irvine | ucirvine | uci | |
University of California--San Diego | ucsd | uc san diego | |
University of Florida | u of f | uoff | |
Lehigh University | lehigh | |
Pepperdine University | pepperdine | |
University of California--Davis | ucd | uc davis | davis | |
University of Miami | miami | |
University of Wisconsin--Madison | uw madison | uwmadison | university of wisconsin | |
University of Michigan--Ann Arbor | umich | university of michigan | u mich |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment