Final Mini Project: Student Task Tracker Automation
Task 1 – Create the Task Data File
File: tasks.csv
id,title,due_date,status
1,Submit Assignment,2025-09-01,Done
2,Buy Groceries,2025-09-03,Pending
3,Call Doctor,2025-09-05,Done
4,Read Python Book,2025-09-05,Done
5,Pay Electricity Bill,2025-08-29,Pending
Explanation:
This file acts as our database. Each row is a task with:
-
id→ unique number for the task -
title→ what needs to be done -
due_date→ when it should be finished -
status→ whether it is Done or Pending
Task 2 – Read Tasks from the File
import csv
def load_tasks(filename):
tasks = []
with open(filename, newline="") as f:
reader = csv.DictReader(f)
for row in reader:
tasks.append(row)
return tasks
tasks = load_tasks("tasks.csv")
print(tasks)
Explanation:
We use Python csv.DictReader to read each line as a dictionary.
Now tasks are stored in Python lists so we can process them.
Task 3 – Analyze the Tasks
from datetime import datetime
def analyze_tasks(tasks):
today = datetime.today().date()
overdue = []
completed = []
pending = []
for task in tasks:
due = datetime.strptime(task["due_date"], "%Y-%m-%d").date()
if task["status"].lower() == "done":
completed.append(task)
elif due < today:
overdue.append(task)
else:
pending.append(task)
return completed, pending, overdue
Explanation:
-
We get today’s date using
datetime.today(). -
If the task is Done → add to completed.
-
If the due date is before today → it’s overdue.
-
Otherwise → it’s pending.
Task 4 – Write a Summary Report
def write_report(completed, pending, overdue, filename="report.txt"):
with open(filename, "w") as f:
f.write("=== Task Summary Report ===n")
f.write(f"Completed: {len(completed)}n")
f.write(f"Pending: {len(pending)}n")
f.write(f"Overdue: {len(overdue)}nn")
f.write("Overdue Tasks:n")
for task in overdue:
f.write(f"- {task['title']} (Due: {task['due_date']})n")
Explanation:
This function creates a text report.
It counts each type of task and lists overdue ones clearly.
Task 5 – Put Everything Together
def main():
tasks = load_tasks("tasks.csv")
completed, pending, overdue = analyze_tasks(tasks)
write_report(completed, pending, overdue)
print("Report generated: report.txt")
if __name__ == "__main__":
main()
Explanation:
This is the full program:
-
Load tasks
-
Analyze them
-
Write report
When you run the file → it generatesreport.txt.
Task 6 – (Optional) Automate the Report Daily
import time
while True:
main()
print("Report updated. Next run in 24 hours...")
time.sleep(86400) # 24 hours = 86400 seconds
Explanation:
-
This creates a loop.
-
After each run, the program sleeps for 24 hours before running again.
-
It simulates daily automation.
Example Output
=== Task Summary Report ===
Completed: 2
Pending: 1
Overdue: 2
Overdue Tasks:
- Call Doctor (Due: 2025-08-25)
- Pay Electricity Bill (Due: 2025-08-29)
