Generate reports from data
✓Works with OpenClaudeYou are a data engineer who needs to generate professional reports from structured data using Python. The user wants to create automated reports with formatting, charts, and export capabilities.
What to check first
- Verify you have
pandas,matplotlib, andreportlabinstalled:pip list | grep -E "pandas|matplotlib|reportlab" - Confirm your data source is accessible (CSV file, database connection, or API endpoint)
- Check that your output directory exists or can be created with
os.makedirs()
Steps
- Import required libraries:
pandasfor data manipulation,matplotlibfor charts, andreportlabfor PDF generation - Load your data using
pd.read_csv(),pd.read_sql(), or your data source method - Clean and aggregate data using
groupby(),agg(), andsort_values()methods to prepare metrics - Generate visualizations with
plt.figure()and save as PNG usingplt.savefig()withdpi=300for report quality - Create a PDF document using
SimpleDocTemplate()from reportlab and define page size withletter - Build report content with
Paragraph,Table,PageBreak, andImageelements, appending to a story list - Apply styling with
ParagraphStyleto set fonts, sizes, and alignment for headers, body text, and tables - Render the final PDF by calling
pdf.build(story)with your assembled content
Code
import pandas as pd
import matplotlib.pyplot as plt
from reportlab.lib.pagesizes import letter, A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Paragraph, Table, TableStyle, PageBreak, Image, Spacer
from reportlab.lib import colors
from datetime import datetime
import os
class ReportGenerator:
def __init__(self, output_path="report.pdf", page_size=letter):
self.output_path = output_path
self.page_size = page_size
self.story = []
self.styles = getSampleStyleSheet()
self._setup_custom_styles()
def _setup_custom_styles(self):
"""Define custom paragraph styles"""
self.styles.add(ParagraphStyle(
name='CustomTitle',
parent=self.styles['Heading1'],
fontSize=24,
textColor=colors.HexColor('#1f4788'),
spaceAfter=30,
alignment=1
))
self.styles.add(ParagraphStyle(
name='CustomHeading',
parent=self.styles['Heading2'],
fontSize=14,
textColor=colors.HexColor('#2e5c8a'),
spaceAfter=12,
spaceBefore=12
))
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Data & Analytics Skills
Other Claude Code skills in the same category — free to download.
CSV Parser
Parse and process CSV files
Data Transformer
Transform data between formats (JSON, XML, CSV)
Analytics Setup
Set up analytics tracking (GA4, Mixpanel, PostHog)
Data Pipeline
Create data processing pipeline
Chart Creator
Create charts and visualizations (Chart.js, D3)
Data Exporter
Export data in multiple formats
ETL Script
Create ETL (Extract, Transform, Load) scripts
Data Validator
Validate data integrity and format
Want a Data & Analytics skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.