diff --git a/grade-data/24S.csv b/grade-data/24S.csv index 22e1740..7bc23d5 100644 --- a/grade-data/24S.csv +++ b/grade-data/24S.csv @@ -1,4 +1,4 @@ -Subject,Catalog Nbr,Section,A+,A,A-,B+,B,B-,C+,C,C-,D+,D,D-,F,CR,I,NC,W,P,Instructor 1,Instructor 2,Instructor 3,Instructor 4,Instructor 5,Instructor 6 +Subject,Catalog Nbr,Section,A+,A,A-,B+,B,B-,C+,C,C-,D+,D,D-,F,CR,I,NC,W,P,Instructor 1,Instructor 2,Instructor 3,Instructor 4,Instructor 5,Instructor 6 ACCT,2301,001,4,6,11,7,7,2,8,6,6,,4,,3,,,,3,,"Zhang, Jieying","Ozel, Naim Bugra","Gu, Dongdi","Zhang, Yang",, ACCT,2301,002,6,9,16,7,11,1,7,4,3,,1,,,,,,2,,"Ozel, Naim Bugra","Zhang, Jieying","Gu, Dongdi","Zhang, Yang",, ACCT,2301,003,8,11,18,6,6,,2,3,5,,3,,1,,,,4,,"Ozel, Naim Bugra","Zhang, Jieying","Gu, Dongdi","Zhang, Yang",, diff --git a/parser/gradeLoader.go b/parser/gradeLoader.go index bc6abdc..ec63150 100644 --- a/parser/gradeLoader.go +++ b/parser/gradeLoader.go @@ -6,6 +6,7 @@ import ( "log" "os" "path/filepath" + "strconv" "strings" ) @@ -126,22 +127,19 @@ func csvToMap(csvFile *os.File, logFile *os.File) map[string][]int { for _, record := range records { // convert grade distribution from string to int - intSlice := make([]int, 0, 13) - var tempInt int + intSlice := [14]int{} for j := 0; j < 13; j++ { - fmt.Sscan(record[aPlusCol+j], &tempInt) - intSlice = append(intSlice, tempInt) + intSlice[j], _ = strconv.Atoi(record[aPlusCol+j]) } // add w number to the grade_distribution slice if wCol != -1 { - fmt.Sscan(record[wCol], &tempInt) + intSlice[13], _ = strconv.Atoi(record[wCol]) } - intSlice = append(intSlice, tempInt) // add new grade distribution to map, keyed by SUBJECT + NUMBER + SECTION distroKey := record[subjectCol] + record[catalogNumberCol] + record[sectionCol] - distroMap[distroKey] = intSlice + distroMap[distroKey] = intSlice[:] } return distroMap } diff --git a/parser/sectionParser.go b/parser/sectionParser.go index 316cd13..12566d1 100644 --- a/parser/sectionParser.go +++ b/parser/sectionParser.go @@ -62,7 +62,9 @@ func parseSection(courseRef *schema.Course, classNum string, syllabusURI string, semesterGrades, exists := GradeMap[session.Name] if exists { - sectionGrades, exists := semesterGrades[courseRef.Subject_prefix+courseRef.Course_number+section.Section_number] + // We have to trim leading zeroes from the section number in order to match properly, since the grade data does not use leading zeroes + trimmedSectionNumber := strings.TrimLeft(section.Section_number, "0") + sectionGrades, exists := semesterGrades[courseRef.Subject_prefix+courseRef.Course_number+trimmedSectionNumber] if exists { section.Grade_distribution = sectionGrades }