I have doubts about how to get to do this python exercise:
Using the notes.csv file, make a program in python that reads the data from that file and builds the following structure:
alumnos = [ {"nombre":"Daniel", "apellidos":"Fustero López", "curso": "1A", "notas":{"FH":3,"LM":4,"ISO":5,"FOL":6,"PAR":7,"SGBG":6}}, {"nombre":"Rafaela", ... } ,...]
Create a program that shows you a menu and you can choose one of these options:
- Shows the list of students with the average grade they have taken. Use a function to calculate the average grade.
- Ask for a course and a subject and show a list of the students of that course with the grades in that subject.
- Request a course and show the percentage of passes for each subject.
- Request a course, and create a file name of the course.txt with the students and the average grade.
At the moment I have this code but there is no way to get it out in any of the ways. How can I do it?
def recorrerLista():
listaNotas = []
primera = True
with open("notas.csv", "r") as fichero:
for linea in fichero:
if primera:
primera = False
continue
else:
alumnos = dict ()
notas = dict ()
listaLinea = linea.split(",")
alumnos['Apellido'] = listaLinea [0]
alumnos['Nombre'] = listaLinea [1]
alumnos['Curso'] = listaLinea [2]
notas['FH'] = listaLinea [3]
notas['LM'] = listaLinea [4]
notas['ISO'] = listaLinea [5]
notas['FOL'] = listaLinea [6]
notas['PAR'] = listaLinea [7]
notas['SGBD'] = listaLinea [8]
alumnos['notas'] = notas
listaNotas.append (alumnos)
print (listaNotas)
recorrerLista()
I am completely stuck in everything, I do not know how to follow the program anymore. This is the .CSV file itself:
Nombre,Apellidos,Curso,FH,LM,ISO,FOL,PAR,SGBD
ACEVEDO JHONG, DANIE,1C,2,0,6,1,1,8
ALCALà NEGRÓN, CHRISTIAN NELSO,1C,3,0,6,10,9,9
ALMORA HERNANDEZ, RAUL EDUARD,1D,4,3,1,3,3,8