{"id":237,"date":"2025-11-20T14:40:01","date_gmt":"2025-11-20T14:40:01","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=237"},"modified":"2025-11-20T14:40:01","modified_gmt":"2025-11-20T14:40:01","slug":"32-real-world-python-projects-automated-report-generator","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=237","title":{"rendered":"32 &#8211; Real-World Python Projects &#8211; Automated Report Generator"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\"><\/h6>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Purpose<\/strong><\/h3>\n\n\n\n<p>Automatically collect data, process it, create charts, generate a PDF or Excel report, and send it \u2014 without manual effort.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Real-World Use Cases<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Weekly Sales Reports<\/li>\n\n\n\n<li>HR Monthly Attendance Reports<\/li>\n\n\n\n<li>Finance KPI Dashboards<\/li>\n\n\n\n<li>Website Traffic Reports<\/li>\n\n\n\n<li>Automated Email Reports<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde0 <strong>What the Project Will Do<\/strong><\/h3>\n\n\n\n<p>\u2714 Load data from CSV\/Excel\/Database<br>\u2714 Process KPIs (totals, growth %, averages)<br>\u2714 Create charts (matplotlib)<br>\u2714 Generate a final <strong>PDF report<\/strong><br>\u2714 Auto-save with a timestamp<br>\u2714 Optional Email Sending Feature<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\uddf0 <strong>Tech Stack<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pandas<\/code><\/li>\n\n\n\n<li><code>matplotlib<\/code><\/li>\n\n\n\n<li><code>reportlab<\/code><\/li>\n\n\n\n<li><code>datetime<\/code><\/li>\n\n\n\n<li><code>smtplib<\/code> (optional for email)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc1 Folder Structure<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Automated_Report_Generator\/\n\u2502\u2500\u2500 data\/\n\u2502     \u251c\u2500\u2500 sales.csv\n\u2502\u2500\u2500 output\/\n\u2502     \u251c\u2500\u2500 reports.pdf\n\u2502\u2500\u2500 report_generator.py\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc4 <strong>Sample Data (sales.csv)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>date,product,units_sold,revenue\n2025-01-01,Mobile,40,400000\n2025-01-02,Laptop,25,750000\n2025-01-03,Tablet,18,270000\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde0 <strong>Full Python Code: <code>report_generator.py<\/code><\/strong><\/h3>\n\n\n\n<p>\u2714 <em>Simple, clean, real-world ready.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport matplotlib.pyplot as plt\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image\nfrom reportlab.lib.styles import getSampleStyleSheet\nfrom datetime import datetime\n\n# Load data\ndf = pd.read_csv(\"data\/sales.csv\")\n\n# Summary metrics\ntotal_revenue = df&#91;\"revenue\"].sum()\ntotal_units = df&#91;\"units_sold\"].sum()\navg_daily_sales = round(df&#91;\"revenue\"].mean(), 2)\n\n# Generate chart\nplt.figure(figsize=(6, 4))\nplt.plot(df&#91;\"date\"], df&#91;\"revenue\"])\nplt.title(\"Daily Revenue Trend\")\nplt.xlabel(\"Date\")\nplt.ylabel(\"Revenue\")\nchart_path = \"output\/chart.png\"\nplt.savefig(chart_path)\nplt.close()\n\n# Build PDF\ntimestamp = datetime.now().strftime(\"%Y-%m-%d_%H-%M\")\npdf_path = f\"output\/Report_{timestamp}.pdf\"\n\nstyles = getSampleStyleSheet()\ndoc = SimpleDocTemplate(pdf_path)\n\ncontent = &#91;]\n\ncontent.append(Paragraph(\"&lt;b&gt;Automated Sales Report&lt;\/b&gt;\", styles&#91;\"Title\"]))\ncontent.append(Spacer(1, 20))\n\ncontent.append(Paragraph(f\"Total Revenue: \u20b9{total_revenue:,}\", styles&#91;\"BodyText\"]))\ncontent.append(Paragraph(f\"Total Units Sold: {total_units}\", styles&#91;\"BodyText\"]))\ncontent.append(Paragraph(f\"Average Daily Revenue: \u20b9{avg_daily_sales:,}\", styles&#91;\"BodyText\"]))\ncontent.append(Spacer(1, 20))\n\ncontent.append(Paragraph(\"&lt;b&gt;Revenue Trend&lt;\/b&gt;\", styles&#91;\"Heading2\"]))\ncontent.append(Image(chart_path, width=500, height=300))\n\ndoc.build(content)\n\nprint(\"Report Created:\", pdf_path)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcca Output PDF Contains:<\/h3>\n\n\n\n<p>\u2714 Title: &#8220;Automated Sales Report&#8221;<br>\u2714 Key metrics<br>\u2714 Line chart of daily revenue<br>\u2714 Auto-generated timestamp<br>\u2714 Professionally formatted output<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\ude80 <strong>Advanced Add-Ons (Optional)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1\ufe0f\u20e3 Email the PDF Automatically<\/h4>\n\n\n\n<p>Use <code>smtplib<\/code> to send a report to the manager every morning.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2\ufe0f\u20e3 Add Multiple Charts<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Product-wise revenue<\/li>\n\n\n\n<li>Weekly averages<\/li>\n\n\n\n<li>Pie chart for categories<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3\ufe0f\u20e3 Use Database Instead of CSV<\/h4>\n\n\n\n<p>MySQL \/ PostgreSQL \/ MongoDB \u2192 pandas \u2192 report.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4\ufe0f\u20e3 Build a Scheduler<\/h4>\n\n\n\n<p>Use <code>schedule<\/code> module:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>schedule.every().day.at(\"09:00\").do(generate_report)\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">5\ufe0f\u20e3 Create a Streamlit Dashboard<\/h4>\n\n\n\n<p>PDF + Live charts + Filters<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Purpose Automatically collect data, process it, create charts, generate a PDF or Excel report, and send it \u2014 without manual effort. Real-World Use Cases \ud83e\udde0 What the Project Will Do \u2714 Load data from CSV\/Excel\/Database\u2714 Process KPIs (totals, growth %, averages)\u2714 Create charts (matplotlib)\u2714 Generate a final PDF report\u2714 Auto-save with a timestamp\u2714 Optional Email [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=237"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions\/238"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}