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.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn 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.
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
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.
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.csvRead 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”.
Related recipes for everyday AI work
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
- Agent Skills
Related
- Data analysis with AI
Cleaning, exploring and charting data with an AI assistant and a repeatable method.
- 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.
- 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.