Spaces:
Runtime error
Runtime error
Update analytics.py
Browse files- analytics.py +34 -29
analytics.py
CHANGED
|
@@ -7,42 +7,47 @@ def write_to_csv_departments(time,teachingscore,teaching,courseContentscore,cour
|
|
| 7 |
examinationscore,examination,labWorkscore,labWork,libraryFacilitiesscore,
|
| 8 |
libraryFacilities,extraCurricularscore,extraCurricular):
|
| 9 |
csv_file_path = 'dataset/database.csv'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
with open(csv_file_path, 'r') as f:
|
| 12 |
-
reader = csv.reader(f)
|
| 13 |
-
for header in reader:
|
| 14 |
-
break
|
| 15 |
-
with open(csv_file_path, "a", newline='') as f:
|
| 16 |
-
writer = csv.DictWriter(f, fieldnames=header)
|
| 17 |
-
dict = {'Timestamp': time, 'teachingscore': teachingscore, 'teaching': teaching,
|
| 18 |
-
'coursecontentscore': courseContentscore, 'coursecontent': courseContent,
|
| 19 |
-
'examinationscore': examinationscore, 'examination': examination,
|
| 20 |
-
'labworkscore': labWorkscore, 'labwork': labWork,'libraryfacilitiesscore': libraryFacilitiesscore,
|
| 21 |
-
'libraryfacilities': libraryFacilities, 'extracurricularscore': extraCurricularscore,
|
| 22 |
-
'extracurricular': extraCurricular, 'Email Address': ''}
|
| 23 |
-
writer.writerow(dict)
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
def write_to_csv_teachers(teacher1,teacher1score,teacher2,teacher2score,teacher3,teacher3score,
|
| 28 |
teacher4,teacher4score,teacher5,teacher5score,teacher6,teacher6score):
|
| 29 |
csv_file_path = 'dataset/teacherdb.csv'
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
def get_counts():
|
|
|
|
| 7 |
examinationscore,examination,labWorkscore,labWork,libraryFacilitiesscore,
|
| 8 |
libraryFacilities,extraCurricularscore,extraCurricular):
|
| 9 |
csv_file_path = 'dataset/database.csv'
|
| 10 |
+
df = pd.read_csv(csv_file_path)
|
| 11 |
+
header = df.columns.tolist()
|
| 12 |
+
|
| 13 |
+
# Creating a dictionary for the new row
|
| 14 |
+
new_row = {'Timestamp': time.time(), 'teachingscore': teachingscore, 'teaching': teaching,
|
| 15 |
+
'coursecontentscore': courseContentscore, 'coursecontent': courseContent,
|
| 16 |
+
'examinationscore': examinationscore, 'examination': examination,
|
| 17 |
+
'labworkscore': labWorkscore, 'labwork': labWork, 'libraryfacilitiesscore': libraryFacilitiesscore,
|
| 18 |
+
'libraryfacilities': libraryFacilities, 'extracurricularscore': extraCurricularscore,
|
| 19 |
+
'extracurricular': extraCurricular, 'Email Address': ''}
|
| 20 |
+
|
| 21 |
+
# Appending the new row to the DataFrame
|
| 22 |
+
df = df.append(new_row, ignore_index=True)
|
| 23 |
+
|
| 24 |
+
# Writing the DataFrame back to the CSV file
|
| 25 |
+
df.to_csv(csv_file_path, index=False)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
def write_to_csv_teachers(teacher1,teacher1score,teacher2,teacher2score,teacher3,teacher3score,
|
| 31 |
teacher4,teacher4score,teacher5,teacher5score,teacher6,teacher6score):
|
| 32 |
csv_file_path = 'dataset/teacherdb.csv'
|
| 33 |
+
|
| 34 |
+
# Read the existing headers
|
| 35 |
+
df = pd.read_csv(csv_file_path)
|
| 36 |
+
header = df.columns.tolist()
|
| 37 |
+
|
| 38 |
+
# Create a dictionary for the new row
|
| 39 |
+
new_row = {'teacher1': teacher1, 'teacher1score': teacher1score,
|
| 40 |
+
'teacher2': teacher2, 'teacher2score': teacher2score,
|
| 41 |
+
'teacher3': teacher3, 'teacher3score': teacher3score,
|
| 42 |
+
'teacher4': teacher4, 'teacher4score': teacher4score,
|
| 43 |
+
'teacher5': teacher5, 'teacher5score': teacher5score,
|
| 44 |
+
'teacher6': teacher6, 'teacher6score': teacher6score}
|
| 45 |
+
|
| 46 |
+
# Append the new row to the DataFrame
|
| 47 |
+
df = df.append(new_row, ignore_index=True)
|
| 48 |
+
|
| 49 |
+
# Write the DataFrame back to the CSV file
|
| 50 |
+
df.to_csv(csv_file_path, index=False)
|
| 51 |
|
| 52 |
|
| 53 |
def get_counts():
|