omarkashif commited on
Commit
c30a2a7
·
verified ·
1 Parent(s): 33bd9ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -40,14 +40,14 @@ class AttendanceTracker:
40
  header = next(reader)
41
  for row in reader:
42
  if row:
43
- name = row[0].lower() # Convert to lower case for case-insensitive matching
44
  existing_data[name] = row[1:] # Store all existing columns for this name
45
 
46
  # Read the new attendance file
47
  new_attendance_list = []
48
  with open(attendance_file.name, "r") as f:
49
  reader = csv.reader(f)
50
- new_attendance_list = [row[0].lower() for row in reader if row]
51
 
52
  # Get current date and prepare the new column name
53
  current_date = date.today().strftime("%d-%m-%Y")
@@ -61,10 +61,8 @@ class AttendanceTracker:
61
 
62
  for name, statuses in existing_data.items():
63
  # Append new status for the new column
64
- if name in new_attendance_list:
65
- statuses.append("Present")
66
- else:
67
- statuses.append("Absent")
68
  updated_rows.append([name] + statuses)
69
 
70
  # Save the updated attendance list locally
 
40
  header = next(reader)
41
  for row in reader:
42
  if row:
43
+ name = row[0] # Preserve original case
44
  existing_data[name] = row[1:] # Store all existing columns for this name
45
 
46
  # Read the new attendance file
47
  new_attendance_list = []
48
  with open(attendance_file.name, "r") as f:
49
  reader = csv.reader(f)
50
+ new_attendance_list = [row[0] for row in reader if row]
51
 
52
  # Get current date and prepare the new column name
53
  current_date = date.today().strftime("%d-%m-%Y")
 
61
 
62
  for name, statuses in existing_data.items():
63
  # Append new status for the new column
64
+ status = "Present" if name in new_attendance_list else "Absent"
65
+ statuses.append(status)
 
 
66
  updated_rows.append([name] + statuses)
67
 
68
  # Save the updated attendance list locally