Random Student Attendance Picker with Python Tkinter and Excel Integration
Install required dependencies:
pip install pandas openpyxl
Read and process student data from an Excel roster (e.g., student_roster.xlsx). The file must contain columns for unique identifiers and full names.
Data Validatoin and Processing
Load the Excel file using Pandas and verify required columns exist:
import pandas as pd
def process_student_data(excel_path):
# Load spreadsheet
roster_df = pd.read_excel(excel_path)
# Extract column headers
column_headers = roster_df.columns.tolist()
# Validate mandatory columns
assert "ID" in column_headers, "Spreadsheet must include an 'ID' column"
assert "Name" in column_headers, "Spreadsheet must include a 'Name' column"
# Transform rows into formatted strings
student_records = [
f"{row['ID']} {row['Name']}"
for _, row in roster_df.iterrows()
]
return student_records
Usage Example
For a spreadsheet with columns ID, Class, Name, and Grade:
# Sample data processing
students = process_student_data("student_roster.xlsx")
print(students[:3]) # Output first 3 records: ['101 Alice', '102 Bob', '103 Charlie']
The function returns a list of strings combining student IDs and names, siutable to random selection algorithms. Subsequent GUI implementation would use Tkinter to display results and trigger random picks.