Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Workflow recipe

Clean and analyse a messy spreadsheet with AI

Clean a messy spreadsheet with ChatGPT or Claude without losing rows: profile it, agree the rules, keep a cleaning log and reconcile totals before any chart.

By Checked Beginner45 min7 steps
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On this page

To clean a spreadsheet with AI, upload a copy with anything sensitive removed, ask ChatGPT or Claude for a profile of the data before any change, agree the cleaning rules in writing, and apply them with a cleaning log. Reconcile the row counts and totals yourself, then ask for charts and save the method for next month.

ChatGPT and Claude can both read a spreadsheet you upload and run code on it to clean and chart the data. That is fast, but it is also easy to end up with a nice chart from data that quietly lost a third of its rows. This recipe keeps three habits: look before changing anything, agree the cleaning rules in writing, and reconcile the row counts at the end.

The example is a sales export with mixed date formats, duplicate rows and inconsistent region names, but the steps work for any table.

Your computerAbout 3 min

1. Make a copy and remove what should not be uploaded

Work on a copy, never the original. Before uploading, delete columns the analysis does not need, especially personal data such as names, emails and phone numbers. If you need to count customers, keep an ID column instead of names.

Check that your organisation allows this data in the AI tool you are using.

ChatGPT or ClaudeAbout 5 min

2. Ask for a profile of the data, with no changes

Upload the file and ask the assistant to describe what it sees. Do not let it clean anything yet.

Profile the data · ChatGPT or Claude with data analysis
I've uploaded [FILE NAME]. Don't change anything yet. Use code to profile it and report: 1. Number of rows and columns, and each column's apparent type. 2. For each column: count of blanks, number of distinct values, and 5 example values. 3. Columns that mix formats (dates, numbers stored as text, currencies). 4. Likely duplicate rows, and how you identified them. 5. Category columns with spelling variants (e.g. "N. America", "North America"). 6. Anything that looks like an error (negative quantities, dates in the future, totals that don't add up). Finish with a numbered list of proposed cleaning rules. Don't apply them.

Write down the total row count. You will need it in step 5.

ChatGPT or ClaudeAbout 7 min

3. Agree the cleaning rules before applying them

Go through the proposed rules one by one. Only you know the business meaning: whether a refund should be a negative row, whether “UK” and “GB” are the same region, whether a blank discount means zero or unknown.

Reply with the final rules in your own words, numbered, for example:

Apply these rules, in order:
1. Trim spaces from all text columns.
2. Parse order_date as day-first dates (dd/mm/yyyy). Rows that fail to parse: keep them, flag them in a new column date_problem.
3. Map region values: "N. America", "NA", "North america" -> "North America"; "UK", "GB" -> "United Kingdom".
4. Remove exact duplicate rows (all columns equal). Do not remove near-duplicates.
5. Blank discount means 0.
6. Keep negative quantities: they are returns. Add a column is_return.

Rules that keep and flag problem rows are safer than rules that delete them.

ChatGPT or ClaudeAbout 5 min

4. Apply the rules and get a cleaning log

Apply and log · ChatGPT or Claude with data analysis
Apply the rules above to the original upload. Then give me: 1. The cleaned file as CSV to download. 2. A cleaning log: for each rule, how many rows or cells it changed. 3. Row counts: original, removed (with the reason for each removal), and final. 4. The complete Python code you ran, as one script that reads the original file and writes the cleaned one, so I can re-run it myself.

SpreadsheetAbout 5 min

5. Reconcile the numbers yourself

Open the cleaned file and check, without the AI:

  • original rows minus removed rows equals final rows,
  • the total of a key amount column (for example revenue) before and after cleaning differs only by the removed duplicates,
  • a few rows you know well look right.

If the numbers do not reconcile, ask the assistant to explain the difference row by row before you go further.

ChatGPT or ClaudeAbout 10 min

6. Ask for three charts that answer real questions

Decide the three questions first, then ask for one chart per question.

Three charts · ChatGPT or Claude with data analysis
Using the cleaned data, make three charts: 1. [QUESTION 1, e.g. "How did monthly revenue change over the last 12 months?"] - line chart, months on the x-axis. 2. [QUESTION 2, e.g. "Which regions contribute most revenue?"] - horizontal bar chart, sorted. 3. [QUESTION 3, e.g. "What share of orders are returns, by product category?"] - bar chart. For each chart: a title that states the finding in plain words, labelled axes with units, no 3D effects, and one sentence underneath on what it shows and any caveat (e.g. partial last month). Give me each chart as a PNG and the numbers behind it as a small table.

Check each chart against its table. A chart title that states a finding must be true of the numbers.

EditorAbout 10 min

7. Write the method so next month takes ten minutes

Save four things in one folder: the original file, the cleaning rules from step 3, the script from step 4 and a short method note.

# Monthly sales clean-up

Source: Sales export from the CRM, "All orders" report, CSV.
Steps:
1. Remove name and email columns before upload.
2. Run clean_sales.py (or upload with the rules in RULES.txt).
3. Reconcile: original rows - removed = final; revenue difference = duplicates only.
4. Charts: monthly revenue, revenue by region, returns by category.
Known issues: the CRM exports dates as dd/mm/yyyy; region names drift when sales add new territories.
Last run: 2026-11-19, 4,812 rows in, 4,790 out (22 exact duplicates).

Next month, you can re-run the script yourself:

pip install pandas
python clean_sales.py sales_2026-12.csv sales_2026-12_clean.csv

Read the script before relying on it. If it hard-codes the file name, ask the assistant to change it to take input and output paths as arguments, as above.

Check it worked

Verification checklist

0 of 6 done

When it goes wrong

If dates come out wrong (3 April read as 4 March), the tool guessed the format. Say explicitly which format the column uses, as in rule 2, and check a few dates where the day is above 12.

If the assistant says it removed duplicates but the count looks too high, ask how it defined a duplicate. “Same customer and date” is not the same as “every column equal”.

If the file is too large to upload, filter it to the period you need first, or ask for the script on a sample and run it yourself on the full file.

Variations

If you work in Google Sheets, Gemini in Sheets can help with formulas and summaries directly in the sheet. The same habits apply: profile first, agree rules, reconcile.

To produce a formatted Excel file with formulas and charts rather than CSV and PNG, Claude can use its built-in spreadsheet skill (the xlsx skill) when file creation is turned on. Ask for “an .xlsx with the cleaned data on one sheet and the charts on another”.

If the numbers live in a database rather than a file, turn a business question into a checked SQL dashboard. For PDFs instead of tables, extract structured data from PDFs. If the sheet holds survey answers or support comments, analyse customer feedback with AI turns them into themes with counts you can check. AI at work basics covers what is safe to share with an assistant, and the AI for non-developers learning path puts this recipe in context. More recipes are in the AI workflow examples hub.

Outcome and tools

Outcome
A cleaned table, three charts and a written method you can repeat.
For
Data analysts, Non-technical
  • Data analysis with AI

    Cleaning, exploring and charting data with an AI assistant and a repeatable method.

    SkillBeginner

  • AI at work: a practical start for non-developers

    Pick the tasks an assistant does well, write instructions you can reuse, work with your own files and check every answer before you use it.

    TutorialBeginner25 min

  • Research a topic with sources you can check

    Research a topic with AI search and keep every claim checkable: build a source list, open and log each source, draft from the log, then add limits and a date.

    WorkflowBeginner30 min6 steps

Back to top