PRIYANSHUDHAKED commited on
Commit
2efe269
·
verified ·
1 Parent(s): 09c1ec7

Update record_attendance.py

Browse files
Files changed (1) hide show
  1. record_attendance.py +14 -17
record_attendance.py CHANGED
@@ -6,18 +6,20 @@ import streamlit as st
6
  def record_attendance_new(present_students: list, subject: str, max_roll_number=26):
7
  # Automatically get the current date in YYYY-MM-DD format
8
  date = datetime.now().strftime("%Y-%m-%d")
9
- length = len(present_students)
10
- st.success(f"{length} students' attendance is going to record.")
11
 
12
  # Convert present_students to integers
13
  present_students = list(map(int, present_students))
14
  print("Present Students:", present_students) # Debugging line
15
- length = len(present_students)
16
- if present_students:
17
- ty = type(present_students[0]).__name__
18
- else:
19
- ty = "No students present in combined_student of present_student" # Get the name of the type as a string
20
- st.success(f"{length} students' roll number is going to record {ty}.")
 
 
21
 
22
  # Get the path of the uploaded CSV file
23
  csv_file_path = f'{subject}.csv'
@@ -53,16 +55,11 @@ def record_attendance_new(present_students: list, subject: str, max_roll_number=
53
  writer = csv.writer(csvfile)
54
  writer.writerows(rows)
55
 
56
- # Create a download button
 
 
57
  with open(csv_file_path, 'r') as file:
58
  csv_contents = file.read()
59
 
60
- st.download_button(
61
- label="Download updated attendance file",
62
- data=csv_contents,
63
- file_name=csv_file_path,
64
- mime='text/csv'
65
- )
66
-
67
- print(f"Attendance recorded for {len(present_students)} students on {date} in {subject}.")
68
 
 
6
  def record_attendance_new(present_students: list, subject: str, max_roll_number=26):
7
  # Automatically get the current date in YYYY-MM-DD format
8
  date = datetime.now().strftime("%Y-%m-%d")
9
+ length = len(present_students)
10
+ st.success(f"{length} students' attendance is going to record.")
11
 
12
  # Convert present_students to integers
13
  present_students = list(map(int, present_students))
14
  print("Present Students:", present_students) # Debugging line
15
+
16
+ length = len(present_students)
17
+ if present_students:
18
+ ty = type(present_students[0]).__name__
19
+ else:
20
+ ty = "No students present in combined_student of present_student"
21
+ # Get the name of the type as a string
22
+ st.success(f"{length} students' roll number is going to record {ty}.")
23
 
24
  # Get the path of the uploaded CSV file
25
  csv_file_path = f'{subject}.csv'
 
55
  writer = csv.writer(csvfile)
56
  writer.writerows(rows)
57
 
58
+ print(f"Attendance recorded for {len(present_students)} students on {date} in {subject}.")
59
+
60
+ # Return the CSV contents as a string
61
  with open(csv_file_path, 'r') as file:
62
  csv_contents = file.read()
63
 
64
+ return csv_contents
 
 
 
 
 
 
 
65