A Python-based tool that automatically generates Key Performance Indicators (KPIs) and Key Metrics from CSV data files using Google's Gemini AI model.
KPI Generator analyzes CSV files and uses AI to intelligently generate relevant KPIs and Key Metrics based on the data structure and content. It processes your data files and outputs markdown reports with generated KPI recommendations.
- Python: 3.11 or higher
- Google API Key: A valid API key for Google's Gemini AI model
Download the KPI Generator project to your local machine.
python -m venv .venvActivate the virtual environment:
.venv\Scripts\activateInstall the required Python packages:
pip install -r requirements.txtOr install them individually:
pip install dotenv>=0.9.9 google-genai>=1.60.0 pandas>=3.0.0 Create a .env file in the project root directory and add your Google API key:
api_key=your_google_api_key_here
Note: Replace your_google_api_key_here with your actual Google Gemini API key. Do not commit this file to version control.
Run the tool using the kpi_gen.bat batch file:
kpi_gen.bat "path_to_data_directory" "filename.csv"- path_to_data_directory: The path to the directory containing your CSV file(s)
- filename.csv: The name of the specific CSV file to analyze
kpi_gen.bat "C:\Users\marcel\Documents\Projects\KPI Generator\sample data" dim_geography.csvThis command will:
- Navigate to the project directory
- Activate the virtual environment
- Process the
dim_geography.csvfile from thesample datadirectory - Generate KPIs based on the data structure
- Save the results as a markdown file in the
markdownsfolder
The tool generates a markdown file with a timestamped name in the markdowns/ directory:
- Example:
response_20260125_165703.md - Contains: AI-generated KPI recommendations based on your data
kpi_gen.bat # Batch script to run the tool
main.py # Main application logic
parser.py # CSV parsing utilities
Prompt.txt # AI prompt template for KPI generation
pyproject.toml # Project configuration and dependencies
README.md # This file
sample data/ # Sample CSV files for testing
dim_geography.csv # Example geography dimension file
markdowns/ # Output directory for generated markdown files
- main.py: Core application that orchestrates CSV reading, AI processing, and markdown output
- parser.py: Handles command-line argument parsing to validate file paths and directory inputs
- Prompt.txt: Contains the system instructions sent to the AI model for KPI generation
- kpi_gen.bat: Windows batch wrapper that sets up the environment and runs the tool
- Ensure Python 3.11+ is installed and added to your PATH
- Verify by running:
python --version
- Check that your
.envfile exists in the project root - Verify the API key is correct and valid
- Ensure your Google Gemini API is enabled in Google Cloud Console
- Check the path in
kpi_gen.batmatches your actual.venvlocation - Update the path if needed:
call path\to\.venv\Scripts\activate.bat
- On Windows, you may need to run the command prompt as Administrator
- Alternatively, run Python scripts directly:
python main.py "path" "filename.csv"
If you prefer not to use the batch file:
python main.py "C:\path\to\data" "filename.csv"To create a standalone executable:
pyinstaller --onefile main.py| Package | Version | Purpose |
|---|---|---|
| dotenv | >=0.9.9 | Load environment variables from .env file |
| google-genai | >=1.60.0 | Google Gemini AI API client |
| pandas | >=3.0.0 | Data analysis and CSV processing |
| pyinstaller | >=6.18.0 | Create standalone executables |
[Add your license information here]
For issues or questions, please refer to the project documentation or contact the development team.