I'm trying to parse the following file:
student_id, 521, 597, 624, 100,
1, 99, 73, 97, 98,
2, 98, 71, 70, 99,
I have the following code:
def load_students(filename):
exercises = []
students = []
grades = []
fr = None
try:
fr = open(filename, 'r')
for line in fr:
tokens = line.strip('\n').split(',')
# Get Exercises
# Need help here
# Get Students
if tokens[0].isdigit():
students.append(tokens[0])
# Get grades
grades.append([int(x) for x in tokens[1:]])
except IOError:
print("IO Error!")
finally:
if fr is not None:
fr.close()
print(exercises)
print(students)
print(grades)
return np.array(exercises), np.array(students), np.array(grades)
How I can get the file header (521,597,624, 100) as an array excluding the student_id
string?