def transform_scores(): files = [p for p in os.listdir("data/scores") if p.endswith("txt")] for score_file in files: year = int(score_file.replace("scores_", "").replace(".txt", "")) filename = "scores_{0}.csv".format(year) with open(os.path.join("data/scores", score_file)) as f: data = parity.parse_scores(f) writer = csv.writer(open(os.path.join("data/scores", filename), "w")) for row in data: writer.writerow(row)
def test_long_college_name(): score = "10/13/1883 Brooklyn Polytechnic Institute 0 Stevens 59" row = [["10/13/1883", "Brooklyn Polytechnic Institute", 0, "Stevens", 59]] assert_equals(row, parity.parse_scores(StringIO(score)))
def test_single_score(): assert_equals(parity.parse_scores(SINGLE_SCORE), SINGLE_OUTPUT)
def test_single_score_with_loc(): assert_equals(parity.parse_scores(LOC_SCORE), LOC_OUTPUT)
def test_scores(): assert_equals(parity.parse_scores(SCORE_FILE), OUTPUT_FILE)