Courses / Learn from zero
Clean CSV with AI suggestions without corrupting the data
Goal: ask AI to inspect a fictional expenses CSV, propose cautious cleaning rules, and independently validate the changed file. Do not upload real bank statements, customer details or sensitive sheets. The example intentionally includes a leading-zero ID, a blank amount and an ambiguous date.
Teaching examples are not claimed live model runs; review each lesson’s limits.
Download practice worksheet ↓Lesson 1: Inventory the columns before making changes
Imagine handing someone a messy box of papers with the order “clean everything.” They might throw away a record that matters. AI can do the equivalent to data. Our fictional CSV starts with receipt_id,date,amount and three rows: 0012,03/04,15, 0013,04/04,, 0014,05/04,0. Prompt: Report possible problems only. Do not modify any values. Treat receipt_id as text, distinguish blank from zero and do not guess date order.
Expected findings: the leading zeros are significant as text, one amount is absent, another is exactly zero, and the dates are ambiguous. Exercise: explain why replacing 0012 with 12 is a data change, not a harmless style improvement. Classification comes before cleaning.
Review question: Why avoid a blanket “clean everything” AI prompt?
It may remove leading zeros, assume dates and fill unknown numbers without evidence.
Lesson 2: Ask AI for a reversible change plan
Prompt: Make a table of problem, recommended action and risk. Do not fill missing values. Every proposed change must be reversible.
Reference rows: preserve receipt_id as text (otherwise leading zeros vanish); leave a missing amount blank and flag it (otherwise calculations change); leave ambiguous dates as-is until you establish the convention. Practice: challenge an AI proposal to interpret all 03/04 entries as March fourth. What evidence supports day-month versus month-day order? If none exists, do not apply the transformation. An attractive spreadsheet is not necessarily an accurate one. Preserve an original copy before doing any work.
Review question: Why is a blank amount not the same as zero?
Blank is unknown, whereas zero is an explicit numeric value.
Lesson 3: Handle duplicates without automatic deletion
Give the assistant two exactly matching rows and another with the same ID but a different amount. Prompt: Mark duplicate_candidate only where all specified fields match. Never delete rows automatically. Explain the reason for each flag.
0012,03/04,15 repeated exactly is a candidate for review; 0012,03/04,20 is a different record despite sharing an ID. Negative test: tell AI to remove the latter simply because the identifier matches. A safe answer pushes back: you need the accounting meaning and source before deleting anything. Exercise: note which rows need human approval. Losing a valid record is worse than temporarily leaving an uncertain duplicate in a review queue.
Review question: Should matching IDs automatically trigger row deletion?
No; compare the full record and validate the domain meaning before deleting.
Lesson 4: Independently inspect any AI-produced CSV
After agreeing to a specific plan, ask AI to produce a proposed output and a change log, not a silent overwrite. Open the file with a local CSV viewer and confirm that 0012 is still preserved, the empty amount remains missing and column order is unchanged.
Intentional failure: output begins with 12,03/04,15. Even though it parses, this is wrong. An imported cell starting with =HYPERLINK(...) may also be interpreted as a formula in some spreadsheet tools, so untrusted CSV content requires application-specific export safety checks. Ask AI to flag cells starting with formula-like characters; validate in the actual viewer you use. This is about correctness and security, not just tidy formatting.
Review question: What must a CSV check confirm after AI changes?
Preserved text IDs, blank-versus-zero distinction, field order and safe handling of imported formulas.
Lesson 5: Deliver data with a reviewable audit trail
Provide original input, AI suggestion, approved revision and a row-by-row difference report. Prompt: Compare each field. Flag a lost leading zero or a blank changed to zero as FAIL. Do not declare success when such a difference exists.
Expected delivery: preserve IDs, leave the missing amount unknown, keep true zero separate, flag ambiguous dates and refrain from automatic deletion. This is a fictional test; no real financial file has been cleaned here. Outcome: you can use AI to inspect and plan CSV cleaning while keeping independent data-quality checks in charge of acceptance.
Review question: What makes the final cleaned CSV acceptable?
A comparison against the original, justified documented changes and unresolved ambiguity clearly flagged.
What did you accomplish?
Finish only when you can complete the final exercise and explain each step’s outcome or limits.
Topic-specific worked final project
Practice input
Fictional CSV with text ID 0012, missing amount for 0013 and a true zero for 0014.
Reference deliverable
AI prompt: “Analyze issues without mutating rows. Preserve IDs as text, do not guess dates or missing amounts.” 0012 preserved; 0013 amount missing; 0014 amount 0; date 03/04 remains ambiguous. FAIL condition: any output changing 0012 to 12 or blank to numeric zero. Deliver original and proposed CSV with a row-by-row audit log.
How do we judge success?
Concrete AI inspection prompt, reversible changes, independent comparison and cautious treatment of unknowns.