import fileparser import dateutil.parser import algorithms #parse begin students = fileparser.parse_students() courses = [] for student in students: for attempt in student.attempts: courses.append(attempt.course) courses = set(courses) courseCodes = set(course.id_num for course in courses) #parse end courseYcode=582219#käyttöjärjestelmä yGrade=0 minsupp=0.2 k_item_set=7 def group(attempts): attempts.sort(key=lambda a: dateutil.parser.parse(a.date)) response = [[attempts[0]]] for i in range(1, len(attempts)): if attempts[i].date != response[-1][-1].date: response.append([attempts[i]]) else: response[-1].append(attempts[i]) return [set(a.course.id_num for a in x) for x in response] def preprocess(students,courses,courseCodes,target_course_code,target_grade): newCode=target_course_code*1000+target_grade newCourse=None for course in courses:
import fileparser as f import algorithms as alg import dateutil.parser import datetime as d students = f.parse_students() adv_prog = "582103" intro_prog = "581325" courseIdToName = {} def process_students(students): processed_students = [] for student in students: record = [{'grade': int(attempt.grade), 'id': str(attempt.course.id_num), 'date': dateutil.parser.parse(attempt.date)} for attempt in student.attempts] for attempt in student.attempts: courseIdToName[int(attempt.course.id_num)] = attempt.course.name record.sort(key=lambda a: a['date']) processed_students.append(record) return processed_students def next_semester_date(date, springmonth, fallmonth): month = date.month if month < fallmonth: return d.datetime(date.year, fallmonth, 1, 0, 0, 0, 0) else: return d.datetime(date.year + 1, springmonth, 1, 0, 0, 0, 0)