Skip to content

Instantly share code, notes, and snippets.

@Darthfett
Created March 7, 2012 15:25
Show Gist options
  • Save Darthfett/1993788 to your computer and use it in GitHub Desktop.
Save Darthfett/1993788 to your computer and use it in GitHub Desktop.
1. Copy and paste ASU class pages into "classes_and_grades.txt" file in same directory. Delete any empty lines and save. 2. Run script in python 3.x.
import os, sys
with open("classes_and_grades.txt") as classes_and_grades:
for line in classes_and_grades:
data = line.split("\t")
fixed = []
for item in data:
stripped = item.strip()
if stripped:
fixed.append(stripped)
course = fixed.pop(0).split(" ")
subject = course.pop(0)
course_number = course.pop(0)
course_name = " ".join(course)
if len(fixed[0]) <= 2:
grade = fixed.pop(0)
grade_str = ("an " if grade.lower()[0] in {"a", "f", "e", "i", "l"} else "a ") + grade
else:
grade = ""
grade_str = "no grade"
professors = fixed.pop().split(", ")
print("You got %s in %s %s (%s), which was taught by: \n\t" % (grade_str, subject, course_number, course_name) + ", ".join(professors))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment