← Back to library

Turn a CSV export into a written report with charts

An Anthropic cookbook notebook that builds a data-analyst agent on Claude Managed Agents. You hand it a CSV; it writes and runs analysis scripts, checks the key numbers, and produces a single HTML report with interactive charts and short commentary, starting with the finding that matters most. A companion notebook turns it into a Slack bot.

  • OutcomeUpload an export and get back an HTML report that opens with the most useful finding, explains it with charts and ends with recommendations.
  • SetupAn afternoon+
  • LevelAdvanced
  • CreditAnthropic
View original
Works with
Claude

Published Oct 20, 2026Updated Oct 20, 2026AI dry run on sample input: passed Oct 20, 2026Source verified Oct 23, 2026

When should you use it?

  • Monthly exports nobody has time to analyze
  • A small team without an analyst
  • Turning sales or support data into a monthly write-up

Not for: Regulated reporting that needs audited figures

What do you need, and what do you get?

You need

  • CSV export
  • Claude Managed Agents API access and Python

You get

  • HTML report with charts and recommendations

How does it work, step by step?

  1. Open the notebookOpen it on GitHub, or clone the repository and run it in Jupyter or Colab.
  2. Add an API keyThe notebook calls the model API; set the key as an environment variable, never in the notebook.
  3. Swap in your dataReplace the example data with a small, anonymized sample of your own.
  4. Check the resultsCompare outputs against what a person would have produced before using it on real work.

The prompt

The original prompt by Anthropic (claude-cookbooks), word for word, with a link to where it was published. Below it is our adapted version with fill-in blanks, if you want it. Works in Claude. Values in lime are placeholders.

Original prompt by Anthropic (claude-cookbooks)

Word for wordby Anthropic (claude-cookbooks)
You are a senior data analyst producing a publication-quality report.

## Style
- Professional and precise. Let the data speak with concrete numbers.
- Short paragraphs (2-3 sentences) between charts.
- Lead with the most actionable finding.

## Execution
- Write .py scripts and run them with `python3 script.py`.
- Sample large tables (`nrows=` / `.sample()`) instead of loading everything.
- Sanity-check key metrics before building narrative around them.

## Charts
- Build each chart as its own `go.Figure()`, embed with
  `fig.to_html(include_plotlyjs=False, full_html=False)`, and load plotly
  from the CDN once in <head>.
- Always set `marker_color` and `template='simple_white'`.

## Output
Write a single self-contained `report.html` to /mnt/session/outputs/
with inline CSS, 3+ embedded plotly charts, and a closing section of
actionable recommendations. Confirm "Saved: report.html" when done.

Exactly as published by Anthropic (claude-cookbooks) in Data analyst agent · anthropics/claude-cookbooks.

Our adapted version (optional)

Fill in the blanks (optional; the copied prompt uses your values)

Adapted prompt3 variables
Analyze the attached CSV of {data_description} and write a short report for {audience}.
Open with the single most actionable finding. Check key totals (row counts, sums) before writing about them and state the checks. Include {number_of_charts} charts with two or three sentences each, and finish with up to three recommendations that follow from the data. Don't speculate beyond what the data shows.

What can go wrong?

  • Check data-handling rules before uploading customer data to any cloud agent.
  • Confirm the headline numbers yourself; sanity checks reduce errors but don't remove them.

Our take

The useful part of this cookbook is the system prompt's discipline: lead with the most actionable finding, sanity-check key metrics before writing about them, and keep commentary short between charts. Those three rules separate a report people read from a wall of charts. In our dry run we gave an assistant with code execution a sample CSV of 1,200 support tickets from a small MSP and our prompt. The report led with a finding that two clients produced 40% of after-hours tickets, showed ticket volume by week, category and client, checked the totals against the row count, and ended with three recommendations, one of which (review those two clients' backup jobs) followed directly from the data. Treat it as the first draft of a monthly report, with someone confirming the headline number. Save the prompt with the exact column descriptions you used, so next month's report is comparable. Changing the instructions every month makes trends hard to read, because you can't tell whether the data moved or the analysis did.

Where the time goes back: A first-pass analysis and write-up of an export arrives without waiting for an analyst.

FAQ

Do I need Managed Agents?
For the notebook as written, yes. Our prompt below gets a similar report from any assistant that can run code on an uploaded file, such as Claude or ChatGPT with data analysis.
Can it answer questions in Slack?
The companion notebook wraps the same agent as a Slack bot that answers questions about an attached CSV.

Source and credit

The original prompt on this page is by Anthropic (claude-cookbooks), shown word for word with a link to where it was published. The summary, notes and adapted version are ours.

Original
Data analyst agent · anthropics/claude-cookbooks
Creator
Anthropic
Published on
GitHub (anthropics/claude-cookbooks)
Original date
Apr 8, 2026
License
MIT
Originally for
Claude
AI dry run
Oct 20, 2026: passed. Dry-run tested by our AI test agent on sample input. Sanity checks stated; recommendations follow from data.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

The original is licensed under the MIT License (Copyright (c) 2023 Anthropic). The original prompt above is reproduced under that license with its copyright notice; our adapted prompt and summary are our own wording.

Are you the creator? Claim or correct this page.

More in Operations & Admin

All 225 Operations & Admin playbooks →

Related playbooks

Operations & AdminWorkflow✓ AI dry run

Log a sales order after checking its paperwork matches

Give one spoken instruction and get the order logged, cross-checked against its paperwork, the commission tracked and a client email drafted.

Credit: Elvis Rigglet (@rassailor)

An afternoon+
Operations & AdminSkill✓ AI dry run

Price a custom manufacturing job with every cost traced

Use the quote-build skill from Anthropic's Claude for Manufacturing plugin to price a make-to-order job from the intake form, similar past jobs and cost history, citing the purchase order or work order behind each cost, spreading setup across every quantity break, keeping margin on a separate internal line and checking the promised date against shop load, with a person releasing the quote.

Credit: anthropics

An afternoon+
Operations & AdminPrompt✓ AI dry run

Stress-test a business decision with an AI pre-mortem

Before committing to a price rise, launch or other big change, have an assistant assume the plan has already gone wrong, rank the likeliest causes with an early signal for each, work out how much loss you can absorb before the change stops paying, list the assumptions underneath with a cheap test for each, and then write the announcement against a scoring rubric it sets first.

Credit: Shubham Vora

Minutes
Operations & AdminSkill✓ AI dry run

Send suppliers an RFQ package that makes bids comparable

Use the supplier-quote-request skill from Anthropic's Claude for Manufacturing plugin to assemble a request for quotes with the drawing at its confirmed revision, a sourced demand picture, quality clauses, commercial terms and a required bid layout, list what is missing, draft one email per supplier for the buyer to send, then read the returned bids into one shape and compare them by quantity break.

Credit: anthropics

Under an hour
Operations & AdminPrompt✓ AI dry run

Turn one finished chore into a saved agent skill

Brief an agent on a real job you just did, correct its first run, save the method as a skill with an approval rule, then schedule it only after it works.

Credit: Argona0x (@Argona0x)

Minutes