grapher/assets/convert.py

43 lines
1003 B
Python
Raw Normal View History

2025-01-08 11:38:31 +01:00
import pandas as pd
import pprint
import sys
sys.path.append('..')
from model import *
df = pd.read_csv("Student_list.csv")
courses = {
'Tutorial 1': 31,
'Tutorial 2': 15,
'Extended Applications': 18,
'Numpy & MatPlotLib': 35,
'SciPy': 20,
'Monte Carlo': 20,
'Pandas & Seaborn': 22,
'Folium': 27
}
# Create Class
clas = Class.create(name='WiSe 24/25')
#print(clas.id)
# Create Courses
for k, v in courses.items():
Lecture.create(title=k, points=v, class_id=clas.id)
#print(l.title, l.points, l.class_id, l.id)
for index, row in df.iterrows():
s = Student.create(
prename=row["First Name"],
surname=row["Last Name"],
sex=row["Sex"],
class_id=clas.id
)
for title, points in list(row.to_dict().items())[3:]:
Submission.create(
student_id=s.id,
lecture_id=Lecture.select().where(Lecture.title == title),
points=points
)