ChatGPTBeginner

How to Analyze a CSV File with ChatGPT Data Analysis

Upload a spreadsheet and let ChatGPT run Python to clean it, compute summaries, and answer questions about your data.

9 minBeginner

ChatGPT's data analysis feature runs real Python in a sandbox, so it can load a spreadsheet, clean it, and compute exact answers rather than estimating. This is far more reliable than asking it to eyeball numbers. This guide walks through uploading a sales CSV and getting trustworthy summaries from it.

What you need

  • A ChatGPT account with file upload available
  • A CSV or Excel file (a few columns and rows is enough to start)
  • A question you want answered about the data

Step 1: Upload the file

Start a chat, click the + (attach) button in the message box, and select your CSV. ChatGPT detects it is data and prepares to analyze it. You can drag the file straight into the input box too.

Step 2: Ask it to inspect the structure first

Before any analysis, ask ChatGPT to show the columns, data types, and the first few rows. This catches problems early, like a date column stored as text or a stray currency symbol that would break math.

ChatGPT — data analysis
You
Load this file and show me the columns, their types, and the first 5 rows.
Agent
Loaded 1,204 rows. Columns: date (object), region (object), product (object), units (int64), revenue (object). Note: revenue is text because it includes $ signs.

Step 3: Clean the data, then summarize

Tell it to fix what it found, then compute what you need. Be specific about the column names so there is no ambiguity. ChatGPT writes and runs the Python for you, but it helps to know roughly what it is doing.

what ChatGPT runs under the hood
import pandas as pd

df = pd.read_csv("sales.csv")
df["revenue"] = (df["revenue"]
                 .str.replace(r"[$,]", "", regex=True)
                 .astype(float))
df["date"] = pd.to_datetime(df["date"])

by_region = (df.groupby("region")["revenue"]
               .sum()
               .sort_values(ascending=False))
print(by_region)

Step 4: Ask follow-up questions and request a chart

Once the data is clean you can keep asking questions in the same chat and the analysis builds on the cleaned table. Ask for a chart and ChatGPT renders it; you can download the image. You can also ask it to save the cleaned data and give you a download link.

Follow-up questions
$Which region had the highest total revenue, and by how much over second place?
West: $482,310, ahead of South ($451,090) by $31,220 (6.9%).
$Plot monthly revenue as a line chart and let me download the cleaned CSV.
$
Verify the numbers
Ask ChatGPT to show the code it ran, then spot-check one figure against the raw file. Because it uses real Python the math is reliable, but a wrong column name or filter can still produce a confident wrong answer.

Result

You went from a messy CSV to a cleaned table, a ranked summary by region, and a downloadable chart, all in one conversation, without opening a spreadsheet app or writing code yourself.

Watch related tutorials

Tags
#data-analysis#csv#python#spreadsheets