Skip to content

Instantly share code, notes, and snippets.

@sreyemnayr
Created October 22, 2019 14:58
Show Gist options
  • Save sreyemnayr/dfbd00ace4e527613b80f4436745fce8 to your computer and use it in GitHub Desktop.
Save sreyemnayr/dfbd00ace4e527613b80f4436745fce8 to your computer and use it in GitHub Desktop.
""" classgrid.py by Ryan Meyers at St. George's Episcopal School ryan.meyers at stgnola dot org
From Alma reports, download the Teacher Schedules by Period/Day report
Open in excel and save as a CSV (this script assumes schedules.csv is the filename
Run python classgrid.py (schedules.csv should be in the same folder)
grid.csv should be generated.
"""
import csv
periods = set()
classrooms = set()
schedules = {}
days_of_week = {
"Monday": "DOW1",
"Tuesday": "DOW2",
"Wednesday": "DOW3",
"Thursday": "DOW4",
"Friday": "DOW5",
}
def replace_dow(s):
for k, v in days_of_week.items():
s = s.replace(v, k)
return s
with open("schedules.csv") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
periods.add(
days_of_week.get(row["Cycle Day"]) + " " + row["Period Abbreviation"]
)
classrooms.add(row["Class Room Number"])
if row["Class Room Number"] not in schedules.keys():
schedules[row["Class Room Number"]] = {"room": row["Class Room Number"]}
schedules[row["Class Room Number"]][
days_of_week.get(row["Cycle Day"]) + " " + row["Period Abbreviation"]
] = (row["Last Name"] + " - " + row["Class Name"])
with open("grid.csv", "w") as gridfile:
writer = csv.writer(gridfile)
writer.writerow(["Room"] + [replace_dow(v) for v in sorted(periods)])
for c in sorted(classrooms):
writer.writerow([c] + [schedules[c].get(v, "") for v in sorted(periods)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment