Purpose
Automatically collect data, process it, create charts, generate a PDF or Excel report, and send it — without manual effort.
Real-World Use Cases
- Weekly Sales Reports
- HR Monthly Attendance Reports
- Finance KPI Dashboards
- Website Traffic Reports
- Automated Email Reports
🧠 What the Project Will Do
✔ Load data from CSV/Excel/Database
✔ Process KPIs (totals, growth %, averages)
✔ Create charts (matplotlib)
✔ Generate a final PDF report
✔ Auto-save with a timestamp
✔ Optional Email Sending Feature
🧰 Tech Stack
pandasmatplotlibreportlabdatetimesmtplib(optional for email)
📁 Folder Structure
Automated_Report_Generator/
│── data/
│ ├── sales.csv
│── output/
│ ├── reports.pdf
│── report_generator.py
📄 Sample Data (sales.csv)
date,product,units_sold,revenue
2025-01-01,Mobile,40,400000
2025-01-02,Laptop,25,750000
2025-01-03,Tablet,18,270000
🧠 Full Python Code: report_generator.py
✔ Simple, clean, real-world ready.
import pandas as pd
import matplotlib.pyplot as plt
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
from reportlab.lib.styles import getSampleStyleSheet
from datetime import datetime
# Load data
df = pd.read_csv("data/sales.csv")
# Summary metrics
total_revenue = df["revenue"].sum()
total_units = df["units_sold"].sum()
avg_daily_sales = round(df["revenue"].mean(), 2)
# Generate chart
plt.figure(figsize=(6, 4))
plt.plot(df["date"], df["revenue"])
plt.title("Daily Revenue Trend")
plt.xlabel("Date")
plt.ylabel("Revenue")
chart_path = "output/chart.png"
plt.savefig(chart_path)
plt.close()
# Build PDF
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
pdf_path = f"output/Report_{timestamp}.pdf"
styles = getSampleStyleSheet()
doc = SimpleDocTemplate(pdf_path)
content = []
content.append(Paragraph("<b>Automated Sales Report</b>", styles["Title"]))
content.append(Spacer(1, 20))
content.append(Paragraph(f"Total Revenue: ₹{total_revenue:,}", styles["BodyText"]))
content.append(Paragraph(f"Total Units Sold: {total_units}", styles["BodyText"]))
content.append(Paragraph(f"Average Daily Revenue: ₹{avg_daily_sales:,}", styles["BodyText"]))
content.append(Spacer(1, 20))
content.append(Paragraph("<b>Revenue Trend</b>", styles["Heading2"]))
content.append(Image(chart_path, width=500, height=300))
doc.build(content)
print("Report Created:", pdf_path)
📊 Output PDF Contains:
✔ Title: “Automated Sales Report”
✔ Key metrics
✔ Line chart of daily revenue
✔ Auto-generated timestamp
✔ Professionally formatted output
🚀 Advanced Add-Ons (Optional)
1️⃣ Email the PDF Automatically
Use smtplib to send a report to the manager every morning.
2️⃣ Add Multiple Charts
- Product-wise revenue
- Weekly averages
- Pie chart for categories
3️⃣ Use Database Instead of CSV
MySQL / PostgreSQL / MongoDB → pandas → report.
4️⃣ Build a Scheduler
Use schedule module:
schedule.every().day.at("09:00").do(generate_report)
5️⃣ Create a Streamlit Dashboard
PDF + Live charts + Filters

Leave a Reply