abhicodes commited on
Commit
5d55959
·
1 Parent(s): 5a27084

Update analytics.py

Browse files
Files changed (1) hide show
  1. analytics.py +15 -10
analytics.py CHANGED
@@ -8,7 +8,6 @@ def write_to_csv_departments(time,teachingscore,teaching,courseContentscore,cour
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, 'teachingscore': teachingscore, 'teaching': teaching,
@@ -22,10 +21,13 @@ def write_to_csv_departments(time,teachingscore,teaching,courseContentscore,cour
22
  new_data = pd.DataFrame(new_row, index=[0])
23
 
24
  # Append the new data to the existing DataFrame
25
- df = df.append(new_data, ignore_index=True)
26
-
27
- # Write the DataFrame back to the CSV file
28
- df.to_csv(csv_file_path, index=False)
 
 
 
29
 
30
 
31
 
@@ -46,11 +48,14 @@ def write_to_csv_teachers(teacher1,teacher1score,teacher2,teacher2score,teacher3
46
  'teacher5': teacher5, 'teacher5score': teacher5score,
47
  'teacher6': teacher6, 'teacher6score': teacher6score}
48
 
49
- # Append the new row to the DataFrame
50
- df = df.append(new_row, ignore_index=True)
51
-
52
- # Write the DataFrame back to the CSV file
53
- df.to_csv(csv_file_path, index=False)
 
 
 
54
 
55
 
56
  def get_counts():
 
8
  libraryFacilities,extraCurricularscore,extraCurricular):
9
  csv_file_path = 'dataset/database.csv'
10
  df = pd.read_csv(csv_file_path)
 
11
 
12
  # Creating a dictionary for the new row
13
  new_row = {'Timestamp': time, 'teachingscore': teachingscore, 'teaching': teaching,
 
21
  new_data = pd.DataFrame(new_row, index=[0])
22
 
23
  # Append the new data to the existing DataFrame
24
+ df2 = pd.concat([df, new_data], ignore_index=True)
25
+
26
+ # Append the new data to the existing DataFrame
27
+ # df = df.append(new_data, ignore_index=True)
28
+ # print(df2)
29
+
30
+ df2.to_csv(csv_file_path, mode='w', index=False)
31
 
32
 
33
 
 
48
  'teacher5': teacher5, 'teacher5score': teacher5score,
49
  'teacher6': teacher6, 'teacher6score': teacher6score}
50
 
51
+ # Concat the new row to the DataFrame
52
+ df2 = pd.concat([df, new_data], ignore_index=True)
53
+
54
+ # Append the new data to the existing DataFrame
55
+ # df = df.append(new_data, ignore_index=True)
56
+ # print(df2)
57
+
58
+ df2.to_csv(csv_file_path, mode='w', index=False)
59
 
60
 
61
  def get_counts():