39 lines
962 B
Python
39 lines
962 B
Python
#!/usr/bin/python3
|
|
import json
|
|
import csv
|
|
|
|
realCourses = {}
|
|
|
|
|
|
# Get all courses from real sample data
|
|
def getSampleCourses(log=False):
|
|
with open("course_selection_data.csv", newline='') as csvfile:
|
|
reader = csv.DictReader(csvfile)
|
|
for row in reader:
|
|
exists = False
|
|
for course in realCourses:
|
|
exists = True if realCourses[course]["CrsNo"] == row["CrsNo"] else False
|
|
if exists: break
|
|
if not exists:
|
|
realCourses[row["CrsNo"]] = {
|
|
"CrsNo": row["CrsNo"],
|
|
"Requests": 0,
|
|
"Description": row["Description"],
|
|
"Credits": 4,
|
|
"Teachers": 3,
|
|
"students": []
|
|
}
|
|
|
|
if log:
|
|
with open("realCourses.json", "w") as outfile:
|
|
json.dump(realCourses, outfile, indent=2)
|
|
|
|
return realCourses
|
|
|
|
|
|
if __name__ == '__main__':
|
|
courseSet = getSampleCourses()
|
|
|
|
with open("realCourses.json", "w") as outfile:
|
|
json.dump(courseSet, outfile, indent=2)
|