def _read_instructors(self, path: str): """ Read each line""" try: data2: Iterator[Tuple[str]] = file_reader( path, 3, sep='\t', header=True) for cwid, name, dept in data2: self._instructors[cwid] = Instructor(cwid, name, dept) except ValueError as i: print(i)
def _read_majors(self, path): """Major details are read using file reading gen and added to dictionary""" try: for major, flag, course in file_reader(path, 3, sep='\t', header=True): if major not in self._majors: self._majors[major] = Major(major) self._majors[major].store_electives(course, flag) except ValueError as v: print(v)
def _read_instructors(self, path: str) -> None: """ Read each line in the file""" try: for cwid, name, dept in file_reader(path, 3, sep='\t', header=False): self._instructors[cwid] = Instructor(cwid, name, dept) except (FileNotFoundError, ValueError) as i: print(i)
def _read_students(self, path: str) -> None: """ Read each line in the file""" try: for cwid, name, major in file_reader(path, 3, sep='\t', header=False): self._students[cwid] = Student(cwid, name, major) # do something except (FileNotFoundError, ValueError) as e: print(e)
def _read_students(self, path: str): """ Read each line""" try: data1: Iterator[Tuple[str]] = file_reader( path, 3, sep='\t', header=True) for cwid, name, major in data1: if major not in self._majors: print( f"Student {cwid} '{name}' informations is undefined '{major}'") else: self._students[cwid] = Student( cwid, name, self._majors[major]) except(FileNotFoundError, ValueError) as e: print(e)
def _read_grades(self, path: str): """Read the students cwid, course, grades, instructors_cwid""" # tell the student about the course and the grade # Look up the student associated with student_cwid, reach, inside, and update the dictionary inside student try: data3 = file_reader(path, 4, sep='\t', header=True) for student_cwid, course, grade, instructor_cwid in data3: if student_cwid in self._students: self._students[student_cwid].store_course_grade( course, grade) else: print( f"Grade for the student {student_cwid} not reflectd in student's file in {course} is {grade}") if instructor_cwid in self._instructors: self._instructors[instructor_cwid].store_course_student( course) else: print( f"Unknown instructor {instructor_cwid} not reflected in the instructor's file") except(FileNotFoundError, ValueError) as j: print(j)