DATA ANALYSIS WITH CLAUDE

How to Use Claude for Data Analysis: CSVs, SQL Queries, and Reports

The spreadsheet doesn't get smaller. Your first pass through it does.

Anthropic's Claude is a capable stand-in for the first hour of any data task: reading a CSV, pulling apart a schema, extracting fields from a stack of PDFs, or summarizing a pile of research. This page covers how to use Claude for data analysis in practice, the prompts that work, and the checks that keep a wrong number out of a report.

How to use Claude for data analysis means handing Anthropic's Claude a CSV, a database schema, or a stack of documents and asking it to find patterns, write SQL queries, pull out structured data, or draft a report in plain language. Claude reads large files in a single conversation, explains its reasoning as it goes, and writes code when that's the better tool, but it does not run code or query your live database on its own; you confirm its output against the source data, a spot-check calculation, or a second pass before it goes anywhere near a decision.

Published · Last reviewed

Free lesson · no account neededThe Iteration LoopMaster the Essentials6 minStart the free lesson

Key Takeaways

  • Claude analyzes CSV files by reading pasted or uploaded data directly in conversation, no separate BI tool required for a first pass.
  • Claude writes SQL queries from a schema description, including joins, window functions, and CTEs, and explains what each part does.
  • Claude extracts structured data from messy text, emails, PDFs, and web pages into a JSON or CSV schema you define.
  • Claude does not execute code or connect to a live database, so every number it produces needs a verification step before it's used.
  • Reports built from Claude's analysis still need a human to confirm the underlying data and catch when a question was framed wrong.

What Claude does directly vs. what you still need to do

A quick gut check before you trust any number Claude gives you.
TaskWhat Claude does directlyWhat still needs a human check
CSV analysisReads pasted or uploaded data, finds trends, flags anomalies, summarizes in plain language.Confirm totals against a pivot table or a second calculation before reporting them.
SQL queriesWrites and explains joins, CTEs, and window functions from a schema description.Run the query yourself and check row counts and edge cases like nulls and duplicates.
Structured extractionPulls fields from messy text into a JSON or CSV schema you define.Spot-check a sample of records against the source document, especially ambiguous fields.
Report draftingTurns data and findings into a narrative with a clear headline and recommendations.Verify every number in the draft traces back to the source data before it ships.
Research synthesisReads multiple sources in one conversation and surfaces agreements, contradictions, and gaps.Check that cited claims actually appear in the source material, not just a plausible summary.

Copy and Paste

Prompts You Can Use Today

Find trends and anomalies in a CSV

Here is a CSV of monthly sales for [number] products over [time period]. Identify which product has the strongest growth trend, any seasonal patterns across the year, months where all products underperformed at once, and the five most significant individual anomalies with a one-line explanation for each.

Paste the raw CSV text, or describe the columns and a representative sample if the file is too large to paste in full.

Generate a SQL query from a schema

My schema is: users (id, email, created_at), orders (id, user_id, amount, status, created_at). Write a [Postgres] query that returns monthly revenue by signup cohort for the past [12] months, including month-over-month growth rate, and explain what each part of the query does.

Swap in your actual table and column names, and name your database engine so the syntax matches.

Extract structured data from unstructured text

Extract the following fields from this job posting as JSON: role_title, company, location, salary_range (null if not listed), required_years_experience, tech_stack as an array, and remote_policy. If any field is ambiguous, add an extraction_notes field explaining the judgment call. Job posting: [paste text]

Define the exact schema you want back; Claude applies it consistently across a batch of documents.

Draft a report from raw data

Here is our [quarter] data for [department]. Write a one-page executive summary: lead with the single most important finding, show the three metrics that matter most with enough context to interpret them, flag one risk, and end with two recommended next steps. Plain language, no jargon.

Give Claude the audience and the length you need; it will match the register.

Turn messy data into a research plan

I have [number] months of customer support ticket data with fields for ticket_id, created_at, category, resolution_time_hours, CSAT_score, agent_id, and product_area. I'm not sure what to look for yet. Suggest the five most valuable analyses I could run on this dataset, what each would tell me, and why it matters for the team.

Useful when you have data but no hypothesis yet; Claude helps you frame the question first.

Ask Claude to explain a query you didn't write

Explain what this SQL query does, step by step, including any joins, subqueries, or window functions. Then tell me if there's a simpler or faster way to write it, and flag any part that looks like it could return duplicate or missing rows. Query: [paste SQL]

Good for inherited queries or when reviewing a teammate's pull request.

FREE LESSONS

Start with the reasoning habits behind good data analysis

A data analyst and someone who's never opened a terminal both start in the same place: learning to give Claude context and check its work.

  1. 1. Master the EssentialsThe Iteration Loop6 min
  2. 2. Master the EssentialsDocument Analysis7 min
  3. 3. Master the EssentialsResearch and Thinking7 min

WORKFLOWS

Six data tasks Claude handles well

These are the jobs that come up most in a normal analysis week.

CSV and spreadsheet analysis

Paste raw CSV data or describe the columns, and ask for descriptive stats, trend lines, anomaly detection, or a cohort comparison in plain language.

SQL query writing

Describe your schema and the question you want answered; Claude writes the query, including joins, aggregations, and window functions, and explains each step.

Structured data extraction

Feed Claude unstructured text, such as emails, PDFs, job postings, or articles, and define the JSON or CSV schema you want back.

Research synthesis

Paste several papers or reports and ask Claude to find findings that repeat across sources, flag contradictions, and name the gaps.

Report generation

Give Claude raw data and an audience; it drafts the narrative, pulls the headline metrics, and writes an executive summary you can edit.

Exploratory data conversations

When you have a dataset and no clear question yet, Claude helps you frame what's worth analyzing and why.

GETTING STARTED

Can Claude analyze a CSV file?

Yes. The most direct way to use Claude for data analysis is to paste a CSV straight into the conversation, or upload the file, and ask a specific question about it. Claude reads the whole file you give it in context rather than sampling a few rows, so it can compare every month, every product line, or every customer segment in one pass.

For a large file, paste the header row plus a representative sample and describe the total row count and any quirks: missing values, inconsistent date formats, a column that's actually two fields mashed together. Claude will reason about the full dataset based on that description, but its confidence is only as good as the sample and the description you give it: a biased sample produces a biased read.

Claude does not open a live spreadsheet or execute your file; it works from what you paste or upload. If you need it to process a file larger than you can paste, or to run the same analysis on a new file every week, it will write you the Python or SQL to do that instead of trying to hold the entire dataset in a chat.

SQL

Can Claude write SQL queries?

Yes, and this is one of the more reliable uses of Claude for data analysis. Describe your schema, including table names, column names, and the relationships between tables, and state the business question you want answered. Claude writes the query and, if you ask, walks through what each clause does and why.

It handles joins, subqueries, common table expressions, and window functions without much prompting, and it will optimize or simplify a query you paste in from somewhere else. The schema matters more than the phrasing of your question: the more precisely you describe your tables, the less Claude has to guess about column names or data types.

Claude does not connect to your database and cannot confirm the query runs or returns the right numbers. Run every query yourself before trusting its output, and check the row count against what you'd expect: a query that returns zero rows or twice as many as expected is telling you something.

EXTRACTION

Can Claude extract structured data from documents?

Yes. Define the exact fields you want, name the type for each one, and tell Claude what to do when a field is missing or ambiguous: null it, flag it, or make its best guess and say so. Claude applies that schema consistently whether you're extracting structured data from one document or fifty, which makes it useful for job postings, invoices, contracts, or scraped web pages.

The failure mode to watch for is a field that looks confidently filled in but was actually inferred rather than stated in the source. Ask Claude to add a notes field for anything it had to infer, and spot-check a sample of the output against the original documents before you load it anywhere downstream.

ACCURACY

How accurate is Claude at data analysis, and how do you check it?

Claude reasons well about statistics and catches a lot of common errors on its own: it will flag when a trend is driven by a single outlier, when a sample is too small to generalize from, or when you're about to compare two numbers that aren't actually comparable. But it can also state a wrong number with the same confident tone as a right one, especially when it's working from a partial sample or a description of data rather than the full dataset.

The fix isn't to distrust everything Claude produces; it's to build a couple of checks into how you use it. Ask it to show its work, not just its conclusion, so you can see where a number came from. Spot-check at least one calculation by hand or against a source you trust. And when a finding is surprising, ask Claude to argue against its own conclusion before you accept it. A quick pre-mortem on a number is often enough to catch a bad assumption.

Treat Claude's first answer as a strong draft, not a finished analysis. That habit is the difference between data analysis with Claude and data analysis that happens to involve Claude.

GETTING SET UP

Do you need to know Python to analyze data with Claude?

No. Everything above works in plain conversation: paste data, ask a question, get an answer in natural language. You don't need to write a line of code to get trend analysis, a SQL query, or a structured extraction out of Claude.

Python becomes useful once you want to repeat an analysis on a new file every week, process a dataset too large to paste, or hand off a reusable script to a teammate. In that case, ask Claude to write the pandas, SQL, or plotting code for you and explain what it does. You're still not writing the code yourself, but you end up with something that runs outside the chat window.

CONTEXT

Giving Claude the context that makes analysis useful

Data analysis prompts work better with more context, not less. For CSVs, that means column definitions and known data quality issues. For SQL queries, it means the actual schema, not a paraphrase of it. For structured data extraction, it means the exact output schema and what to do with edge cases. For reports, it means the audience and what decision the report is meant to support.

The Iteration Loop lesson in Master the Essentials covers this directly: treat the first response as a draft, then correct the context and re-ask rather than starting over with a longer prompt. For data work specifically, the correction is usually a missing piece of schema or a data quirk you forgot to mention, not a flaw in how you phrased the question.

LIMITS

Is it safe to upload business data to Claude, and what are the limits?

Treat any data you paste or upload the way you'd treat data in an email: don't include anything you wouldn't be comfortable a vendor's systems processing, and check your organization's data handling policy before uploading customer records, financial details, or anything with personal information attached. When in doubt, strip identifying columns or work from an aggregated version of the dataset.

The bigger limit isn't privacy, it's verification. Claude doesn't have access to your live database, your BI dashboard, or your actual spreadsheet file unless you give it the data directly, so it can reason well about what you've shown it but can't independently confirm a number is right. Every report, chart description, or headline metric that comes out of a Claude conversation needs to trace back to a source before it reaches a client, a customer, a student, or a colleague.

This is a professional responsibility question as much as a technical one: the person who sends the report is accountable for what's in it, not the tool that helped draft it.

WHERE TO START

A starter path for data work with Claude

Master the Essentials is the fastest way into this. The Iteration Loop lesson teaches the core habit behind every workflow above: treat Claude's first pass as a draft, correct it with better context, and re-ask rather than starting over. Document Analysis covers how Claude reads and reasons about a file you hand it, which is exactly what's happening when you paste in a CSV or a stack of reports. Research and Thinking covers synthesizing multiple sources into one clear answer, the same skill behind research synthesis and report writing.

Those three lessons, in that order, cover the reasoning habits behind every data workflow on this page. From there, the prompts above are templates you can adapt to your own schema, your own dataset, and your own report format.

Get hands-on with data analysis

Reading about prompts for CSVs and SQL is different from actually running them against your own data. The free Nightschool AI curriculum starts with The Iteration Loop, the habit that makes every data prompt on this page work better the second time.

Frequently Asked Questions

Can Claude analyze a CSV file?

Yes. Paste the CSV directly into a conversation or upload it, and ask a specific question about trends, anomalies, or comparisons. Claude reads the entire file you give it in one pass rather than sampling rows, so it can compare figures across an entire dataset at once. For files too large to paste, describe the columns and a representative sample instead.

Can Claude write SQL queries?

Yes. Describe your database schema, including table and column names, and state the question you want answered. Claude writes queries that handle joins, aggregations, subqueries, and window functions, and can explain each part or optimize a query you already have. You still need to run the query yourself to confirm it returns the right rows.

How accurate is Claude at data analysis?

Claude reasons well about statistics and often catches issues like small sample sizes or a misleading comparison on its own. But it can state an incorrect number with the same confident tone as a correct one, particularly when working from a partial sample. Treat its first answer as a strong draft and verify key numbers before using them.

Can Claude extract structured data from documents?

Yes. Define the exact fields and format you want, such as a JSON schema, and Claude applies it consistently across emails, PDFs, contracts, or web pages. Ask it to flag anything it had to infer rather than found stated directly, and spot-check a sample of the output against the source documents.

How do I check Claude's analysis for errors?

Ask it to show its work rather than just a conclusion, so you can see where each number came from. Spot-check at least one calculation by hand or against a trusted source. For surprising findings, ask Claude to argue against its own conclusion before you accept it. That alone catches a lot of bad assumptions.

Is it safe to upload business data to Claude?

Check your organization's data handling policy before uploading customer records, financial details, or personal information, and consider stripping identifying columns or aggregating the data first. Claude doesn't retain independent access to your systems beyond what you share in the conversation, but the responsibility for what data you share is yours.

Do I need to know Python to analyze data with Claude?

No. Everything from trend analysis to SQL generation to structured extraction works in plain conversation without writing code. Python becomes useful if you want to repeat an analysis on new files automatically or hand off a reusable script, and Claude can write that code for you when you need it.

Can Claude build charts or visualizations from data?

Claude can write the code to generate a chart, such as a plotting script in Python, but it doesn't run that code or render a chart for you inside the conversation on its own. Ask it for the chart code and a description of what the chart should show, then run it in your own environment.

Start where the habit forms

The prompt gets better once the habit does.

Nightschool AI is an independent learning platform and is not affiliated with, endorsed by, or sponsored by Anthropic. Claude is a trademark of Anthropic, PBC. Looking for Anthropic's official Claude Academy? It's at academy.claude.com.