I am currently doing a small project for a club in my school. The idea is to filter the GPA of students if they are above a cutoff point based on their class (Freshmen, Sophomore, Junior, and Senior).
Here's an easy example; let's say I have the following .xlsx file:
So based on their credit hours they are part of a class. If they have x < 30
Credits they are a Freshmen, x =< 59 && x >= 30
they are a sophomore, x =< 89 && x >= 60
they are a junior, and if they have x >= 90
credits they are a senior.
So the cut off for the GPA is different for each class. These are the cut offs:
- (
x < 30
)Freshmen: 1.5 - (
x =< 59 && x >= 30
)Sophomore: 2.0 - (
x =< 89 && x >= 60
)Junior: 2.5 - (
x >= 90
)Senior: 3.0
So in our case if we were to filter this data our output would be:
I've been learning how to use xlsxwriter but I'm not sure if there's an easier way to filter something this simple.
I just need to understand how to read the data from this inputted Excel file and read the correct column to filter.
This is a way I believe could work in order to filter (just a pseudo code I mocked up):
for row_line in credits_column:
grade_level = column_line[1] #This would be our Credits Column
#check the grade level
#Check if they're a Senior
if grade_level >= 90:
if gpa_level >= 3.0:
#Keep this row!
else:
#Hide/Delete this row!
#Check if they're a Junior
elif grade_level =< 89 && grade_level >= 60:
if gpa_level >= 2.5:
#Keep this row!
else:
#Hide/Delete this row!
elif grade_level =< 59 && grade_level >= 30:
if gpa_level >= 2.0:
#Keep this row!
else:
#Hide/Delete this row!
elif grade_level < 30:
if gpa_level >= 1.5:
#Keep this row!
else:
#Hide/Delete this row.
# Move on to the next worksheet row.
row += 1
How could I grab the information on both the Credit Column and GPA column correctly, then filter?