Spaces:
Build error
Build error
Update app.py
Browse files
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]
|
| 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]
|
| 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 |
-
|
| 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
|