0% found this document useful (0 votes)
42 views24 pages

Acknowledgement

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views24 pages

Acknowledgement

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

ACKNOWLEDGEMENT

Apart from the efforts of us, the success of any project depends
largely on the encouragement and guidelines of many others. I take
this opportunity to express my gratitude to the people who have
been instrumental in the successful completion of this project.

I express deep sense of gratitude to almighty God for giving me


strength for the successful completion of the project.

I gratefully acknowledge the contribution of my team mate who


contributed in bringing this project up to this level and continued to
look after me despite my flaws.

I express my deep sense of gratitude to the luminary, the Principal,


Mrs. Safeena Parveen, Al-Hira Model School, who has been
continuously motivating and extending their helping hand to us.

My sincere thanks to Mrs. Shabnam Naim, the teacher in-charge, A


guide, mentor who critically reviewed my project and helped in
solving each and every problem, occurred during implementation of
the project.
INDEX
S.NO TITLE
1. SYNOPSIS
2. SOURCE CODE
3. OUTPUT
4. BIBILIOGRAPHY
SYNOPSIS
Project Title: Attendance Management System

Objective:
The Attendance Management System is a comprehensive Python
application designed to efficiently handle and manage student
attendance records. The program allows users to add, update, and
remove student information, as well as to mark attendance,
generate various attendance reports, and export data to a CSV file.
It uses JSON for data storage and PrettyTable for displaying tabular
data, making it user-friendly and suitable for educational
institutions.

Key Features:
1. Add Student: Allows the addition of new students to the
system by specifying a unique student ID and name. This feature
ensures that each student is recorded with an identifier and their
name for easy reference.
2. Update Student Name: Enables the updating of a student's
name based on their student ID. This function is useful for
correcting or updating student information as needed.
3. Remove Student: Provides the ability to remove students
from the system using their student ID. This feature ensures that
outdated or incorrect student records can be managed effectively.
4. Mark Attendance: Facilitates the marking of student
attendance on a specific date. Users can record whether a student
was present or absent, allowing for accurate tracking of attendance
over time.
5. View Attendance: Displays a comprehensive table of
attendance records for all students. This view includes student IDs,
names, dates, and their attendance status, providing a quick
overview of attendance data.
6. Generate Report: Creates a summary report showing the
number of present and absent days for each student. This report
helps in evaluating student attendance patterns over a period.
7. Generate Daily Report: Produces a report detailing
attendance for a specific date. This feature allows users to view
which students were present or absent on any given day.
8. Generate Monthly Report: Compiles a report of attendance
for a particular month, summarizing the number of present and
absent days for each student. This is useful for monthly
assessments and record-keeping.
9. Search Student: Allows users to search for students by their
name or ID. This functionality helps in quickly locating and
retrieving specific student information from the system.
10. Export to CSV: Exports all attendance records to a CSV file
format. This feature provides a way to back up data and perform
further analysis using spreadsheet software.

Technical Details:
➢ Data Storage: Attendance records are stored in a JSON file,
ensuring easy data manipulation and retrieval.
➢ Reporting: Reports and attendance views are generated
using the PrettyTable module, which formats data into
readable tables.
➢ CSV Export: Data is exported to a CSV file for easy sharing
and analysis using standard spreadsheet tools.
➢ Error Handling: Includes basic error handling for file
operations and date formatting to ensure smooth operation.

Usage:
The system is designed to be operated through a console-based
menu, where users can select various options to manage student
attendance. It is suitable for educational institutions, training
centers, or any organization that requires a systematic approach to
tracking attendance.
Benefits:
➢ Simplifies the management of attendance records.
➢ Provides clear and comprehensive reports on student
attendance.
➢ Allows for easy data export and integration with other tools
for further analysis.

Conclusion:
The Attendance Management System is a practical and efficient tool
for handling attendance records, offering essential functionalities
needed for effective attendance tracking and reporting. Its simple
interface and key features make it a valuable asset for managing
student attendance in an organized manner.
SOurCE CODE
import json
import os
import csv
from datetime import datetime
from prettytable import PrettyTable

# File name to store the attendance data


attendance_file = "attendance_management_system_records.json"

# Load attendance data from file


def load_data():
if not os.path.exists(attendance_file):
return {}
try:
with open(attendance_file, 'r') as file:
return json.load(file)
except json.JSONDecodeError:
return {}

# Save attendance data to file


def save_data(data):
try:
with open(attendance_file, 'w') as file:
json.dump(data, file, indent=4)
except IOError:
print("\nError saving data. Please check file permissions.")

# Function to add a new student


def add_student(student_id, student_name):
data = load_data()
student_id = student_id.upper()
if student_id in data:
print(f"\nStudent ID {student_id} already exists.")
return
data[student_id] = {"name": student_name, "attendance": {}}
save_data(data)
print(f"\nStudent {student_name} added successfully with ID {student_id}.")

# Function to update a student's name


def update_student_name(student_id, new_name):
data = load_data()
student_id = student_id.upper()
if student_id not in data:
print(f"\nStudent ID {student_id} not found.")
return
data[student_id]["name"] = new_name
save_data(data)
print(f"\nStudent ID {student_id} name updated to {new_name}.")

# Function to remove a student


def remove_student(student_id):
data = load_data()
student_id = student_id.upper()
if student_id not in data:
print(f"\nStudent ID {student_id} not found.")
return
del data[student_id]
save_data(data)
print(f"\nStudent ID {student_id} removed successfully.")

# Function to mark attendance


def mark_attendance(student_id, date, present=True):
data = load_data()
student_id = student_id.upper()
if student_id not in data:
print(f"\nStudent ID {student_id} not found.")
return
try:
datetime.strptime(date, "%Y-%m-%d") # Validate date format
data[student_id]["attendance"][date] = "Present" if present else "Absent"
save_data(data)
print(f"\nAttendance marked for student ID {student_id} on {date}.")
except ValueError:
print("\nInvalid date format. Please use YYYY-MM-DD.")

# Function to view attendance records


def view_attendance():
data = load_data()
if not data:
print("\nNo attendance records found.")
return

table = PrettyTable()
table.field_names = ["Student ID", "Name", "Date", "Status"]

for student_id, details in data.items():


name = details["name"]
attendance = details["attendance"]
for date, status in attendance.items():
table.add_row([student_id, name, date, status])

print("\nAttendance Records:")
print(table)

# Function to generate attendance report


def generate_report():
data = load_data()
if not data:
print("\nNo attendance records found.")
return

table = PrettyTable()
table.field_names = ["Student ID", "Name", "Present Days", "Absent Days"]

for student_id, details in data.items():


name = details["name"]
attendance = details["attendance"]
present_days = sum(1 for status in attendance.values() if status == "Present")
absent_days = sum(1 for status in attendance.values() if status == "Absent")
table.add_row([student_id, name, present_days, absent_days])

print("\nAttendance Summary Report:")


print(table)

# Function to generate daily report


def generate_daily_report(date):
data = load_data()
if not data:
print("\nNo attendance records found.")
return

table = PrettyTable()
table.field_names = ["Student ID", "Name", "Status"]

for student_id, details in data.items():


name = details["name"]
status = details["attendance"].get(date, "Absent")
table.add_row([student_id, name, status])

print(f"\nAttendance report for {date}:")


print(table)

# Function to generate monthly report


def generate_monthly_report(month):
data = load_data()
if not data:
print("\nNo attendance records found.")
return

table = PrettyTable()
table.field_names = ["Student ID", "Name", "Present Days", "Absent Days"]

for student_id, details in data.items():


name = details["name"]
monthly_attendance = {date: status for date, status in
details["attendance"].items() if date.startswith(month)}
present_days = sum(1 for status in monthly_attendance.values() if status ==
"Present")
absent_days = sum(1 for status in monthly_attendance.values() if status ==
"Absent")
table.add_row([student_id, name, present_days, absent_days])

print(f"\nAttendance report for {month}:")


print(table)

# Function to search for a student by name or ID


def search_student(query):
data = load_data()
query = query.lower()
results = {student_id: details for student_id, details in data.items() if query in
student_id.lower() or query in details["name"].lower()}
if not results:
print(f"\nNo students found for query '{query}'.")
return

table = PrettyTable()
table.field_names = ["Student ID", "Name"]

for student_id, details in results.items():


table.add_row([student_id, details["name"]])

print(f"\nSearch Results for '{query}':")


print(table)

# Function to export attendance report to CSV


def export_to_csv():
data = load_data()
if not data:
print("\nNo attendance records found.")
return

try:
with open('attendance_management_system_report.csv', 'w', newline='') as
csvfile:
fieldnames = ['Student ID', 'Name', 'Date', 'Status']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()

for student_id, details in data.items():


name = details["name"]
for date, status in details["attendance"].items():
writer.writerow({'Student ID': student_id, 'Name': name, 'Date': date,
'Status': status})

print("\nAttendance report exported to


'attendance_management_system_report.csv'.")
except IOError:
print("\nError exporting data. Please check file permissions.")

# Main function to handle user input


def main():
while True:
print("\n" + "="*80)
print(" " * 22 + " Attendance Management System ")
print("="*80)
print("1. Add Student")
print("2. Update Student Name")
print("3. Remove Student")
print("4. Mark Attendance")
print("5. View Attendance")
print("6. Generate Report")
print("7. Generate Daily Report")
print("8. Generate Monthly Report")
print("9. Search Student")
print("10. Export to CSV")
print("11. Exit")
print("="*80)

choice = input("Enter your choice (1-11): ").strip()

if choice == '1':
student_id = input("Enter student ID: ").strip()
student_name = input("Enter student name: ").strip()
add_student(student_id, student_name)
elif choice == '2':
student_id = input("Enter student ID: ").strip()
new_name = input("Enter new student name: ").strip()
update_student_name(student_id, new_name)
elif choice == '3':
student_id = input("Enter student ID: ").strip()
remove_student(student_id)
elif choice == '4':
student_id = input("Enter student ID: ").strip()
date = input("Enter date (YYYY-MM-DD): ").strip()
status = input("Enter 'P' for present or 'A' for absent: ").strip()
mark_attendance(student_id, date, present=(status.upper() == 'P'))
elif choice == '5':
view_attendance()
elif choice == '6':
generate_report()
elif choice == '7':
date = input("Enter date (YYYY-MM-DD): ").strip()
generate_daily_report(date)
elif choice == '8':
month = input("Enter month (YYYY-MM): ").strip()
generate_monthly_report(month)
elif choice == '9':
query = input("Enter student name or ID to search: ").strip()
search_student(query)
elif choice == '10':
export_to_csv()
elif choice == '11':
print("\nExiting the system. Goodbye!")
break
else:
print("\nInvalid choice. Please enter a number between 1 and 11.")

if __name__ == "__main__":
main()
OuTPuT
===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 1
Enter student ID: 12b01
Enter student name: Suhail

Student Suhail added successfully with ID 12B01.

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 2
Enter student ID: 12b16
Enter new student name: Mifraz

Student ID 12B16 name updated to Mifraz.

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 3
Enter student ID: 12b17

Student ID 12B17 removed successfully.


===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 3
Enter student ID: 12b10

Student ID 12B10 removed successfully.

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 4
Enter student ID: 12b09
Enter date (YYYY-MM-DD): 2024-08-06
Enter 'P' for present or 'A' for absent: p

Attendance marked for student ID 12B09 on 2024-08-06.

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 5

Attendance Records:
+---------------+-------------+----------------+------------+
| Student ID | Name | Date | Status |
+---------------+-------------+----------------+------------+
| 12B01 | Suhail | 2024-08-05 | Present |
| 12B01 | Suhail | 2024-08-06 | Present |
| 12B02 | Farhaan | 2024-08-05 | Present |
| 12B02 | Farhaan | 2024-08-06 | Absent |
| 12B06 | Kaif | 2024-08-05 | Absent |
| 12B07 | Hameed | 2024-08-05 | Present |
| 12B07 | Hameed | 2024-08-06 | Present |
| 12B09 | Anas | 2024-08-05 | Absent |
| 12B09 | Anas | 2024-08-06 | Present |
| 12B15 | Khaja | 2024-08-05 | Absent |
| 12B15 | Khaja | 2024-08-06 | Present |
| 12B16 | Mifraz | 2024-08-05 | Absent |
| 12B16 | Mifraz | 2024-08-06 | Present |
+---------------+-------------+-----------------+------------+

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 6

Attendance Summary Report:


+---------------+------------+------------------+------------------+
| Student ID | Name | Present Days | Absent Days |
+---------------+------------+------------------+------------------+
| 12B01 | Suhail | 2 | 0 |
| 12B02 | Farhaan | 1 | 1 |
| 12B06 | Kaif | 0 | 1 |
| 12B07 | Hameed | 2 | 0 |
| 12B09 | Anas | 1 | 1 |
| 12B15 | Khaja | 1 | 1 |
| 12B16 | Mifraz | 1 | 1 |
+--------------+------------+-------------------+------------------+
===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 7
Enter date (YYYY-MM-DD): 2024-08-05

Attendance report for 2024-08-05:


+---------------+-------------+-----------+
| Student ID | Name | Status |
+---------------+-------------+-----------+
| 12B01 | Suhail | Present |
| 12B02 | Farhaan | Present |
| 12B06 | Kaif | Absent |
| 12B07 | Hameed |Present |
| 12B09 | Anas | Absent |
| 12B15 | Khaja | Absent |
| 12B16 | Mifraz | Absent |
+---------------+------------+-------------+
===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 8
Enter month (YYYY-MM): 2024-03

Attendance report for 2024-03:


+---------------+-------------+------------------+------------------+
| Student ID | Name | Present Days | Absent Days |
+---------------+-------------+------------------+------------------+
| 12B01 | Suhail | 0 | 0 |
| 12B02 | Farhaan | 0 | 0 |
| 12B06 | Kaif | 0 | 0 |
| 12B07 | Hameed | 0 | 0 |
| 12B09 | Anas | 0 | 0 |
| 12B15 | Khaja | 0 | 0 |
| 12B16 | Mifraz | 0 | 0 |
+---------------+-------------+-------------------+-----------------+

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 9
Enter student name or ID to search: 12b07

Search Results for '12b07':


+---------------+------------+
| Student ID | Name |
+---------------+------------+
| 12B07 | Hameed |
+---------------+------------+

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 10

Attendance report exported to 'attendance_management_system_report.csv'.

===================================================================
Attendance Management System
===================================================================
1. Add Student
2. Update Student Name
3. Remove Student
4. Mark Attendance
5. View Attendance
6. Generate Report
7. Generate Daily Report
8. Generate Monthly Report
9. Search Student
10. Export to CSV
11. Exit
===================================================================
Enter your choice (1-11): 11

Exiting the system. Goodbye!


BIBLIOGrAPhY
➢COMPUTER SCIENCE WITH PYTHON FOR
CLASS 12 – SUMITA ARORA

➢https://www.geeksforgeeks.org

➢https://www.pythonforall.com

➢https://www.scribd.com

You might also like