def _read_instructors_file(self, path): """read the instructors file""" try: for cwid, name, dept in file_reading_gen(path, 3, sep='|', header=True): self._instructors[cwid] = Instructor(cwid, name, dept) except FileNotFoundError as fne: print(fne) except ValueError as ve: print(ve)
def _read_student_file(self, path): """read the student file""" try: for cwid, name, major in file_reading_gen(path, 3, sep=';', header=True): self._students[cwid] = Student(cwid, name, major) self._students[cwid].add_major(major, self._majors) except FileNotFoundError as fne: print(fne) except ValueError as ve: print(ve)
def _read_majors_file(self, path): """read the majors file""" try: for dept, flag, courses in file_reading_gen(path, 3, sep='\t', header=True): # print(dept,flag, courses) if dept in self._majors: self._majors[dept].add_courses(flag, courses) else: self._majors[dept] = Major(dept) self._majors[dept].add_courses(flag, courses) except FileNotFoundError as fne: print(fne) except ValueError as ve: print(ve)
def _read_grades_file(self, path): """read the grades file""" try: for cwid, course, grade, instructor_cwid in file_reading_gen( path, 4, sep='|', header=True): if cwid in self._students: self._students[cwid].add_courses(course, grade) else: print(f"Found grade for unknown student{cwid}") if instructor_cwid in self._instructors: self._instructors[instructor_cwid].add_courses(course) else: print(f"Got course of unknown instructor{instructor_cwid}") except FileNotFoundError as fne: print(fne) except ValueError as ve: print(ve)