How to Use Claude Code for Data Analysis — Practical Guide
You have data. Sales CSVs, Google Analytics exports, inventory spreadsheets, ERP reports. But turning all of this into actionable insights is the part that gets stuck. Complex formulas in Excel, R language that no one understands, BI dashboards that cost thousands per month.
Claude Code solves this in a simple way: you point to a data file, ask what you want to know in Portuguese, and it analyzes, processes and responds. No formulas, no programming, no expensive tools.
In this guide, you'll see real-world examples of data analysis with Claude Code -- from simple CSVs to SQL queries, from GA4 metrics to interactive dashboards.
1. Why Claude Code for Data
Claude Code has a critical advantage over common chatbots for data analysis: itaccess your files directly e execute code in your terminal. This means that:
- No need to copy data to a chat-- it reads the file directly from your computer
- Process large files-- CSVs with millions of lines, which wouldn't fit in a chat
- Generates reusable scripts-- the analysis becomes a Python script that you run every month
- Runs and shows results-- it's not just a code suggestion, it runs and shows the output
- Iterate over errors-- if the CSV has wrong encoding or unexpected columns, it detects and adjusts
Practical advantage:With the context of 1M tokens, Claude Code can keep in memory the analysis of several files simultaneously. You can cross-reference sales data with marketing data with inventory data in a single session.
2. Parsing CSV files
CSV is the most common format for exchanging data. Claude Code reads and analyzes any CSV, regardless of size or format.
Step 1: initial exploration
geral: quantas linhas, quais colunas, tipos de dados,
valores nulos, e as primeiras 5 linhas como exemplo.
Claude Code runs a script with pandas and returns:
Step 2: specific questions
Now that you know the structure, ask what you need:
1. Faturamento total e por trimestre
2. Top 10 produtos por receita
3. Regiao com maior crescimento Q4 vs Q3
4. Dia da semana com mais vendas
5. Ha alguma anomalia nos dados?
Claude Code generates and executes the analysis script, presenting each answer with concrete data. If it detects anomalies (such as a day with revenue 10x above average), it automatically alerts and investigates.
3. Example: complete sales analysis
Let's look at an end-to-end example. You have a sales CSV and want a complete report:
- resumo executivo (faturamento, ticket medio, total pedidos)
- analise mensal com tendencia
- top 10 produtos e categorias
- analise por regiao
- cohort de clientes (novos vs recorrentes)
- salve o script como analise_vendas.py to eu reutilizar
Claude Code generates a complete script:
This script is reusable. Every month, update the CSV and runpython analise_vendas.pyto have the report updated.
4. Analyzing GA4 data
Google Analytics 4 allows you to export data in CSV or connect via BigQuery. Claude Code analyzes both formats.
CSV export from GA4
- paginas mais visitadas
- taxa de bounce por pagina
- fontes de trafego que mais convertem
- funil: visita > adicionar carrinho > compra
- sugestoes de otimizacao baseadas nos dados
Claude Code reads the export, identifies the relevant metrics (sessions, engaged_sessions, conversions, bounce_rate) and generates actionable insights. It can compare with previous periods if you provide both files.
Crossing GA4 with sales data
(vendas-2025.csv) por data. Quero ver: correlacao entre
trafego e vendas, quais fontes de trafego geram mais
receita, e qual o cost por aquisicao por canal.
The ability to cross multiple datasets is where Claude Code really stands out. It reads both files, joins by date (or another key), and generates analyzes that would be complex in any other tool.
5. Working with SQL
Claude Code also works with SQL databases. For SQLite, it accesses directly. For PostgreSQL and MySQL, it generates connection scripts.
todas as tabelas, total de registros por tabela, e os 10
clientes com maior valor acumulado de pedidos.
Query optimization
Claude Code also helps optimize slow queries:
e sugira indices e reescrita to otimizar:
SELECT ... FROM orders JOIN products ... WHERE ...
That up there? Skills do automatically.
Every technique you're reading about can be turned into a skill — a command that Claude executes perfectly, every time. The Mega Bundle has 748+ ready-made skills for marketing, dev, SEO, copy and more.
Ver Skills Prontas — $96. Creating visualizations and dashboards
Table data is useful, but graphs communicate better. Claude Code can generate visualizations in several ways:
Graphing with matplotlib
1. Faturamento mensal (barras)
2. Distribuicao por categoria (pizza)
3. Tendencia de ticket medio (linha)
Salve como imagens PNG em /graficos/
Interactive HTML Dashboard
For something more sophisticated, Claude Code can generate a complete HTML dashboard with Chart.js:
Use Chart.js. Inclua: KPIs no topo (faturamento, ticket
medio, total pedidos), grafico de barras mensal, grafico
de pizza por categoria, e tabela com top 10 produtos.
Salve como dashboard.html
The result is an HTML file that you open in the browser -- with interactive graphics, hover with values, responsive on cell phones. Without installing anything, without a server, just open the file.
7. Generating automated reports
Claude Code can generate reports formatted in several formats:
| Format | When to use | How Claude Code generates |
|---|---|---|
| Markdown | Internal reports, documentation | Generates .md with tables, headers and metrics |
| HTML | Share with clients/team | Page formatted with graphics |
| CSV | Data processed for reimport | Clean export with calculated metrics |
| JSON | Integration with other systems | Structured data for APIs |
com: resumo executivo, metricas vs mes anterior (com setas
de crescimento/queda), top produtos, alerta de produtos com
queda >20%, e recomendacoes baseadas nos dados.
8. Automation of recurring analyzes
The most powerful part: transforming manual analyzes into automated scripts that run every week or month.
Reusable script with tometers
aceite: --arquivo (caminho do CSV), --periodo (mes/trimestre/
ano), --formato (html/markdown/json), --output (arquivo de
saida). Documente como usar.
Combining with /loop for monitoring
pelo ERP) e me alerte se: faturamento do dia estiver 30%
abaixo da media, algum produto zerou estoque, ou ticket
medio caiu mais de 15%.
Automated monitoring of KPIs in real time. Claude Code runs the analysis every hour and only alerts you when it finds anomalies.
Tip:Specialized skills for data analysis make the difference. Instead of explaining the report format every time, a skill/relatorio-vendasYou already have all the metrics, format and logic configured. The package ofskills dev from minhakills.ioincludes skills for data science, analytics and report automation.
Stop doing it by hand. Let the skills work.
Professionals who use skills deliver 3x faster. It's not theory — it's 748+ skills tested on real projects, organized by area. Install once, use forever.
Get the Mega Bundle — $9FAQ
Yes. Claude Code reads CSV files directly from your file system. It can open the file, understand the column structure, identify data types, and perform full analysis using pandas or Python scripts. You can ask for specific metrics, comparisons between periods, anomaly detection, and more -- all in natural language.
Yes. Claude Code can generate visualizations using matplotlib, plotly or even create interactive HTML dashboards with Chart.js. It creates bar, line, pie, scatter charts and more. For more sophisticated dashboards, it can generate an HTML page complete with interactive charts that you open in the browser.
Yes. Claude Code can connect to SQLite databases directly and execute queries. For PostgreSQL, MySQL and others, it can generate Python scripts that connect to the database, execute queries and process the results. It can also analyze SQL dumps, optimize slow queries and create reports from database data.