Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,13 +41,13 @@ class AttendanceTracker:
|
|
| 41 |
for row in reader:
|
| 42 |
if row:
|
| 43 |
name = row[0] # Preserve original case
|
| 44 |
-
existing_data[name] = row
|
| 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")
|
|
@@ -59,11 +59,11 @@ class AttendanceTracker:
|
|
| 59 |
if new_column_name not in updated_header:
|
| 60 |
updated_header.append(new_column_name)
|
| 61 |
|
| 62 |
-
for
|
| 63 |
# Append new status for the new column
|
| 64 |
-
status = "Present" if
|
| 65 |
-
|
| 66 |
-
updated_rows.append(
|
| 67 |
|
| 68 |
# Save the updated attendance list locally
|
| 69 |
with open(local_file_path, "w", newline="") as f:
|
|
|
|
| 41 |
for row in reader:
|
| 42 |
if row:
|
| 43 |
name = row[0] # Preserve original case
|
| 44 |
+
existing_data[name.lower()] = row # Store the entire row with the original case
|
| 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].strip().lower() for row in reader if row] # Convert to lower case for comparison
|
| 51 |
|
| 52 |
# Get current date and prepare the new column name
|
| 53 |
current_date = date.today().strftime("%d-%m-%Y")
|
|
|
|
| 59 |
if new_column_name not in updated_header:
|
| 60 |
updated_header.append(new_column_name)
|
| 61 |
|
| 62 |
+
for name_lower, row in existing_data.items():
|
| 63 |
# Append new status for the new column
|
| 64 |
+
status = "Present" if name_lower in new_attendance_list else "Absent"
|
| 65 |
+
row.append(status)
|
| 66 |
+
updated_rows.append(row)
|
| 67 |
|
| 68 |
# Save the updated attendance list locally
|
| 69 |
with open(local_file_path, "w", newline="") as f:
|