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[1:] #
|
| 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")
|
|
@@ -65,6 +65,11 @@ class AttendanceTracker:
|
|
| 65 |
statuses.append(status)
|
| 66 |
updated_rows.append([name] + statuses)
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
# Save the updated attendance list locally
|
| 69 |
with open(local_file_path, "w", newline="") as f:
|
| 70 |
writer = csv.writer(f)
|
|
|
|
| 41 |
for row in reader:
|
| 42 |
if row:
|
| 43 |
name = row[0] # Preserve original case
|
| 44 |
+
existing_data[name.lower()] = row[1:] # Use lower case for matching
|
| 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] # Normalize new names for case-insensitive comparison
|
| 51 |
|
| 52 |
# Get current date and prepare the new column name
|
| 53 |
current_date = date.today().strftime("%d-%m-%Y")
|
|
|
|
| 65 |
statuses.append(status)
|
| 66 |
updated_rows.append([name] + statuses)
|
| 67 |
|
| 68 |
+
# Add entries for any new names not in existing data
|
| 69 |
+
for name in new_attendance_list:
|
| 70 |
+
if name not in existing_data:
|
| 71 |
+
updated_rows.append([name] + ["Absent"] * len(updated_header[1:]))
|
| 72 |
+
|
| 73 |
# Save the updated attendance list locally
|
| 74 |
with open(local_file_path, "w", newline="") as f:
|
| 75 |
writer = csv.writer(f)
|