Applied AI-Powered Business Tools

Business Report Generator

Last reviewed

Advanced

What you'll learn

~90-120 min
  • Build a Python CLI tool that transforms CSV data into polished executive reports
  • Understand the data analysis pipeline: ingestion, statistical analysis, visualization, and presentation
  • Configure report generation with YAML settings for themes, charts, and metrics
  • Apply automation thinking to eliminate repetitive reporting workflows

What you’re building

MIS students write reports constantly. Financial summaries, operations dashboards, quarterly reviews, market analysis write-ups — they all follow the same structure: title page, executive summary, data tables, charts, key findings, recommendations. Every single time, you spend hours formatting in Word, tweaking Excel charts, and copy-pasting numbers.

In this lesson you will build a Python CLI tool that takes a CSV file as input and generates a polished, presentation-ready HTML executive report with auto-generated charts, summary statistics, styled data tables, and an executive summary section. Run one command, get a complete report. Open it in a browser, print it to PDF, and submit it.

This is the MIS track’s first command-line build. You are moving from browser tools (Lesson 1) and React apps (Lessons 2-3) to a command-line tool that processes files on disk. This is how automation works in the real world — scripts that take input, produce output, and integrate into workflows.

ℹPrerequisites: Python jump

This lesson uses Python with pandas, plotly, and Jinja2: a different stack from the React lessons in Lessons 2-3. If you have not used Python before, the AI handles the setup. Verify you have Python 3.12 or newer installed: run python3 --version. On Ubuntu or WSL, install it and the virtual-environment module once with sudo apt install python3 python3-venv; elsewhere use your package manager or python.org.


The showcase

When finished, your CLI tool will:

  • Accept a CSV file and an optional report title from the command line.
  • Auto-analyze the data: detect column types, compute descriptive statistics, identify trends, find outliers.
  • Generate a styled HTML report containing:
    • Title page with report name, date, and data summary.
    • Executive summary: 3-5 bullet points highlighting key findings (highest values, biggest changes, notable outliers).
    • KPI section: large-format numbers for the most important metrics.
    • Charts section: auto-generated bar, line, and pie charts using Plotly (embedded in the HTML).
    • Data tables: paginated, sortable tables with conditional formatting.
    • Statistical summary: descriptive statistics for all numeric columns.
    • Methodology note: what data was analyzed, how many rows/columns, any data quality issues found.
  • Print-ready: the HTML includes print CSS media queries so it looks good when printed to PDF from the browser.
  • Configurable: a YAML config file controls which charts to generate, report branding, and statistical thresholds.

Think of it as an automated analyst that turns raw data into a deliverable.

ℹMIS Connection: Business Intelligence and Reporting

Report generation is the final mile of any analytics workflow. In business intelligence and capstone courses, you are graded on the quality of your deliverables as much as the analysis itself. This tool automates the formatting so you can focus on the analysis and interpretation. In industry, automated reporting pipelines (built with tools like Python, R Markdown, or Tableau Server) save analysts dozens of hours per month. Building one yourself demonstrates both technical skill and business process understanding.


Before you start

First, if your AI tool is still open, leave it: type /exit and press Enter (if you use Antigravity, press Ctrl+D with nothing typed instead), and wait until you see the $ or % prompt. Make a clean folder for this lesson inside your course folder:

Terminal window
mkdir -p ~/mis-workbench/04-business-report-generator && cd ~/mis-workbench/04-business-report-generator

On Windows PowerShell, run mkdir -Force ~/mis-workbench/04-business-report-generator; cd ~/mis-workbench/04-business-report-generator, or open the folder in your desktop agent app. Then start your agent the way your track’s setup lesson showed.

Switch to plan mode

Once your agent is open, switch to Plan mode inside the session (Shift+Tab, /plan, or your desktop app’s mode picker). In plan mode it asks clarifying questions and shows you a plan before building.

The conversation

Each message below is an example. Say it in your own words.

Say what you want

Start with a short plain-English description of what you want to build:

I want to build a command-line tool that reads a CSV file and generates a print-ready HTML executive report with summary statistics, interactive charts, tables, and a settings file. Ask me what you need first.

Answer its questions

Your agent will ask a few questions to define the report layout, options, and sample data. Answer each briefly:

If it asksYou might say
What language and command-line options should it use?Use standard Python data and charting tools, with options for input, output, title, config, theme, and no-charts.
What sections and charts should the HTML report include?Title page, executive summary with KPI cards, interactive charts, formatted tables, methodology notes, and clean print layout.
How should the charts be embedded in the HTML?Load the charting script once in the page header so the report stays clean and fast.
Which color themes should be supported?Support corporate navy, modern dark slate, and minimal black-and-white themes, plus clean print page breaks.
Should we generate a realistic sample dataset to test with?Yes, create sample_data/quarterly_sales.csv with 60 rows of seasonal sales across regions, categories, and reps.

Read the plan

Before approving, check the plan for four domain essentials (your agent will typically propose Python with pandas, plotly, pyyaml, and jinja2):

  1. Automated analysis covers stats, trends, and quality. The analyzer detects numeric, categorical, and date columns, computes descriptive statistics, flags outliers beyond 2 standard deviations and correlations above |r| > 0.7, and notes missing values or duplicate rows.
  2. Plotly loads once in the HTML head. Each chart is rendered with include_plotlyjs=False and full_html=False, while the Jinja2 template loads Plotly.js once in <head>, keeping the HTML clean and responsive.
  3. Print CSS keeps charts intact across pages. Major sections start on clean page breaks and chart containers use break-inside: avoid so Ctrl+P (or Cmd+P) prints to PDF without splitting charts in half.
  4. A realistic sample CSV and YAML config are included. Running python -m report_generator --input sample_data/quarterly_sales.csv --output report.html works on the first run and reflects seasonal Q4 sales trends.

If the first plan embeds the charting library inside every chart or omits the sample CSV, say so briefly:

Load the charting script only once in the page header instead of repeating it in every chart, and include the 60-row sample_data/quarterly_sales.csv file.

When the plan covers all four, approve it: pick the option to proceed or say Yes, go ahead and build it (in Codex, press Shift+Tab first to leave plan mode). Once you verify the generated report opens cleanly in your browser, ask your agent to save a Git checkpoint:

Save a checkpoint with Git so we can roll back if needed.
💡The sample data matters

Realistic sample data produces realistic reports. If the sample CSV is random noise, the auto-generated findings will be meaningless. Seasonal patterns and regional differences give the analyzer real trends to detect and report on.


What you get

Ask your agent to set up the Python environment, install the required packages, and generate your first report from the sample CSV:

Set up a virtual environment, install what the tool needs, and run it on sample_data/quarterly_sales.csv to create report.html titled "Q4 2024 Sales Performance Report".

If you prefer running the commands yourself in a terminal instead (on Windows PowerShell, activate the environment with .venv\Scripts\Activate.ps1 instead of source .venv/bin/activate):

Terminal window
cd report-generator
# Ubuntu / WSL, once: sudo apt install python3 python3-venv
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
python -m report_generator --input sample_data/quarterly_sales.csv --output report.html --title "Q4 2024 Sales Performance Report"

Expected output

The generated file looks like this:

report.html (~800-1200 lines of styled HTML with embedded Plotly charts)

Open report.html in your browser. You should see:

  1. Title page with “Q4 2024 Sales Performance Report”, the generation date, and a data summary showing 60 rows and 8 columns.
  2. Executive summary with findings like “West region generated the highest total revenue at $X” and “Revenue increased 15% from Q1 to Q4, driven primarily by Electronics.”
  3. KPI cards showing total revenue, average customer satisfaction, total units sold, and the top-performing region.
  4. Charts: a horizontal bar chart of revenue by category, a line chart showing monthly revenue trends, a pie chart of regional contribution, and a correlation heatmap.
  5. Data tables with summary statistics, top 10 transactions, and a category breakdown pivot table.
  6. Print-ready: press Ctrl+P (or Cmd+P on Mac) and the print preview should show clean page breaks, no interactive elements, and properly sized charts.
⚠Verify auto-generated findings

The executive summary and key findings are generated by code, not by human analysis. Always spot-check the numbers against the raw data — automated aggregations can misidentify trends, miscalculate percentages, or flag misleading patterns (such as a 250% increase driven by a partial first month). Treat AI-generated insights as a starting point for your analysis, not a finished product.

⚠Plotly file sizes

As written, the report loads Plotly.js once from a CDN (include_plotlyjs=False on each chart plus one script tag in the template head), so charts need an internet connection when the report opens. For a fully offline file, ask for the library to be embedded once (include_plotlyjs=True on the first chart only); Plotly’s docs put that at about 3 MB, and current builds are larger. If you need a smaller file, use the --no-charts flag for a text-only report, or add a follow-up prompt to use Chart.js instead (smaller library, less interactivity).


When things go wrong

Python CLI tools introduce a new category of issues: dependency management, file I/O, and data parsing errors. Here is how to diagnose the most common problems.

🔧

When Things Go Wrong

Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.

Symptom
ModuleNotFoundError when running the report generator
Evidence
python -m report_generator --input data.csv --output report.html gives: ModuleNotFoundError: No module named 'plotly'
What to ask the AI
"Running the report generator gives a missing module error. Please check that all required packages are listed in the project dependencies, install them in the virtual environment, and verify the sample report command runs cleanly."
Symptom
Charts render as blank white rectangles in the HTML report
Evidence
The report HTML opens fine, the title page and data tables look correct, but all chart sections show empty white boxes where Plotly charts should be.
What to ask the AI
"The report opens in my browser, but the chart boxes are blank white rectangles. Make sure the charting script is loaded in the HTML header so all embedded charts render visibly when I open report.html."
Symptom
Report crashes on CSV files with missing values or mixed data types
Evidence
Running the tool on a real-world CSV (not the sample data) gives: ValueError: could not convert string to float: 'N/A'. The CSV has blank cells and 'N/A' entries in numeric columns.
What to ask the AI
"The report crashes when a CSV has blank cells or text like 'N/A' in numeric columns. Treat common blank markers ('N/A', 'NA', 'null', '-') as missing values, ignore them when computing averages, and report the missing counts in the methodology section."
Symptom
Print to PDF cuts charts in half across page breaks
Evidence
When I press Ctrl+P in Chrome, the print preview shows Plotly charts split between two pages. The top half of a chart is at the bottom of page 2 and the bottom half is at the top of page 3.
What to ask the AI
"When I print the report to PDF from my browser, charts get sliced in half across page breaks. Update the print styles so each chart stays together on a single page and major report sections start on clean page breaks."
Symptom
Data aggregation produces wrong numbers in the category breakdown table
Evidence
The category breakdown table shows Electronics with total Revenue of $12,000 but manually summing the Revenue column in the CSV for Electronics gives $45,600. The pie chart percentages also look wrong.
What to ask the AI
"The category breakdown table and pie chart show totals that do not match the sum of the Revenue column in the CSV. Make sure revenue is parsed as numbers and summed accurately by category across both the table and the chart."

How it works

The report generator follows a pipeline pattern common in data engineering:

  1. CLI (cli.py) parses arguments with argparse and orchestrates the pipeline. It loads the config, reads the CSV into a Pandas DataFrame, passes it through the analyzer, chart builder, and report builder in sequence.

  2. Analyzer (analyzer.py) uses Pandas to compute descriptive statistics (df.describe()), detect column types (df.dtypes), find correlations (df.corr()), and identify outliers (values beyond mean +/- threshold * std). The key findings are generated by comparing aggregated values: group by each categorical column, compute means, and report the highest/lowest.

  3. Chart Builder (chart_builder.py) uses Plotly Express and Plotly Graph Objects to create each chart. Each chart is rendered as an HTML div string using plotly.io.to_html(fig, include_plotlyjs=False, full_html=False). Only one copy of Plotly.js is included in the final report (in the template head).

  4. Report Builder (report_builder.py) loads the Jinja2 template, fills in all the analysis results and chart divs, and writes the final HTML file. Jinja2 handles the looping (iterating over charts, table rows, findings) and conditional logic (showing data quality warnings only if issues exist).

  5. Config (config.py) loads the YAML file and merges it with defaults. This means the tool works with zero configuration but can be customized by editing the YAML.

🔍For Developers: The Jinja2 template pattern

Jinja2 is the same template engine used by Flask, Django, and Ansible. Learning it here transfers directly to web development and DevOps. The template file (report.html) contains HTML with special tags like {{ title }} for variable insertion and {% for finding in findings %} for loops. The Python code passes a dictionary of values to the template, and Jinja2 renders the final HTML. This separation of logic (Python) and presentation (HTML template) is a fundamental design pattern in software engineering.

🔍From Manual Reports to Automated Pipelines: The Business Caseclick to expand

The report generator you just built automates a single step: turning a CSV into a formatted report. In enterprise settings, this is part of a larger reporting pipeline that runs automatically:

  1. Data extraction: A scheduled script pulls data from a database, API, or file share (e.g., a nightly SQL query against the sales database).
  2. Data transformation: The raw data is cleaned, aggregated, and enriched (e.g., joining sales data with customer demographics).
  3. Report generation: Your tool runs, producing the HTML or PDF report.
  4. Distribution: The report is emailed to stakeholders, uploaded to SharePoint, or published to a dashboard portal.
  5. Archival: Previous reports are stored with timestamps for historical comparison.

Tools used in industry for each step:

  • Extraction: Python scripts, SSIS (SQL Server), Informatica, Fivetran
  • Transformation: pandas, dbt, SQL stored procedures, Power Query
  • Report generation: Python + Jinja2 (what you built), R Markdown, a hosted BI service
  • Distribution: smtplib (Python email), Microsoft Power Automate, Airflow
  • Archival: Amazon S3, Azure Blob Storage, network file shares

The ROI calculation: If a report takes 2 hours to produce manually and is generated weekly for 10 clients, that is 20 hours/week or ~1,000 hours/year. At a loaded cost of $50/hour for an analyst, that is $50,000/year spent on formatting. Your automation reduces it to the time it takes to run one command per client — about 10 minutes/week total. The savings fund the automation effort many times over.

This is the kind of analysis MIS graduates are expected to make: not just “can I build this?” but “should we build this, and what is the business impact?”


Customize it

Add comparison reports

Add a --compare flag that takes a second CSV and generates a side-by-side comparison report with delta charts and color-coded percentage changes.

Add PDF direct output

⚠WeasyPrint on Windows

WeasyPrint requires OS-level C libraries (GTK3, Pango) that do not install via pip alone on Windows. If you are on Windows, either use WSL (recommended) or stick with the browser’s Ctrl+P “Print to PDF” feature. On macOS and Linux, pip install weasyprint usually works directly.

Add a --pdf flag that exports a direct PDF report with page numbers, headers, static chart images, and an HTML fallback if PDF libraries are unavailable.

Static chart image export in Plotly uses the kaleido package; Kaleido 1.x also needs Chrome, so if export fails, run kaleido_get_chrome once (kaleido on PyPI).

Add natural language customization

Add a --focus flag that takes a plain-English filter instruction like "West region in Q4" and filters the dataset before generating the report.

Add scheduled reports

Add a --schedule flag that prints a cron job or task command, regenerates the report only when the CSV hash changes, and logs runs.
ℹMIS Connection: Automating Business Processes

What you just built is a Robotic Process Automation (RPA) workflow in miniature. In business and information systems coursework, you learn about automating repetitive business processes to improve efficiency and reduce errors. This report generator takes a task that manually takes 2-3 hours (data analysis, chart creation, formatting, writing summaries) and reduces it to a 10-second command. Multiply that across an organization producing weekly reports for 50 clients, and you have saved 100-150 hours per week. That is the business case for automation — and you can now build it.


The story so far

Across four lessons, you have built:

LessonToolTechnologyMIS Application
1Business Analytics DashboardSingle HTML + Chart.jsData exploration, BI
2Database Schema DesignerReact + ViteDatabase design, data modeling
3Project Management TrackerReact + ViteProject management, Agile
4Business Report GeneratorPython CLIReporting, automation

Each one demonstrates a different technical skill (front-end, full-stack, back-end automation) applied to a real MIS domain. But the report generator raises a question: where does the CSV come from? In the next two lessons, you will build the data plumbing (ETL pipeline) and the automation layer (scheduled orchestrator) that make these tools production-ready.


Try it yourself

  1. Build the report tool by talking your agent through the plan above.
  2. Run it on the included sample data and open the HTML report.
  3. Read the executive summary. Does it accurately describe the data? If a finding is wrong, look at the analyzer code and figure out why.
  4. Try the different themes: --theme corporate, --theme modern, --theme minimal. Print each to PDF and compare.
  5. Now find a real CSV from your coursework — any dataset from an MIS or statistics class. Run the tool on it. How good is the auto-generated analysis?
  6. Edit the config.yaml to change the color palette and currency symbol. Re-run and see the changes.
  7. Pick one customization from the list above and add it with a follow-up prompt.

Key Takeaways

  • Automation is the highest-value MIS skill. Taking a 2-hour manual process and reducing it to a 10-second command is exactly what MIS professionals are hired to do. This report generator is a concrete example you can point to.
  • The pipeline pattern (input, process, output) applies everywhere. CLI arguments define the input, the analyzer and chart builder do the processing, and the Jinja2 template produces the output. This is the same pattern used in ETL pipelines, CI/CD systems, and data engineering workflows.
  • Configuration separates policy from mechanism. The YAML config file lets you change the report’s appearance, metric thresholds, and chart types without touching the code. This is a fundamental principle in systems design.
  • Print-ready HTML is a powerful output format. Unlike Word documents (hard to generate programmatically) or raw PDFs (complex libraries), HTML with print CSS gives you interactive reports that also look professional when printed. One format, two use cases.
  • Real-world data is messy. The sample CSV works perfectly, but your coursework CSVs will have missing values, inconsistent formatting, and mixed data types. Learning to handle these edge cases (see the troubleshooting section) is the difference between a demo and a real tool.

Portfolio Suggestion

The report generator is a strong portfolio piece on its own. Include 2-3 sample reports generated from different datasets (sales data, survey results, financial data) and commit the HTML reports so visitors can download and open them. The full portfolio strategy — combining all six MIS tools into a single showcase repository — is covered in Lesson 6 after you complete the entire module.


KNOWLEDGE CHECK

You run the report generator on a CSV from your statistics class. The executive summary says 'Revenue showed a 250% increase from January to December.' You check the CSV and see that January had $200 in revenue (a partial month when the business launched) and December had $700. The finding is technically correct but misleading. What is the best approach?


What’s next

In the next lesson, you will build an Automated ETL Pipeline — a Python CLI tool that extracts data from multiple source formats (CSV, JSON, API), applies SQL transformations (JOINs, aggregations, deduplication), and loads clean data into a SQLite database. It is the data plumbing that feeds the dashboards and reports you have already built.

intellimetrics · Arlington, VA
© 2026 intellimetrics.net
Search lessons