Get your API key

Lesson 2 of 5

Clean before you count, with a cleaning log

Fix Rs text amounts, dd-mm-yyyy dates, state spellings and duplicates, with rows before and after every step written down.

8 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson you will have a cleaned sales file, a cleaning log that shows rows before and after every step, and a saved list of every row you removed.

You need: your workbench from lesson 1 with your anonymised sales file or practice_sales.csv, and Excel or Google Sheets to check · Time: 8 minutes

  1. Our example is sales_q2.csv: 4,812 invoices from July to September 2026 for a lighting distributor in Ahmedabad. Yours may be the practice file; the steps are the same.

    Before any cleaning, give the AI the rules for the whole session. Two ideas matter most:

    • Raw stays raw. The original file is never changed. Cleaned data goes to a new file. With an agent, keep the original in a raw folder inside the project; in Colab, the original is the copy on your laptop.
    • A cleaning log. A small table where every step writes one line: what changed, rows before, rows after, and proof. At the end it tells you, and your manager, exactly what happened to the data.
    Prompt · copy it into your AI agent
    We are going to clean [sales_q2.csv] step by step. Rules for this whole session:
    1. Never change or overwrite [sales_q2.csv]. Write the cleaned data to sales_clean.csv.
    2. Do one step at a time, and wait for my OK before the next step.
    3. After every step, print: step number, what changed, rows before, rows after, number of cells changed, and 3 example rows before and after.
    4. Add the same line to cleaning_log.csv (columns: step, what_changed, rows_before, rows_after, cells_changed, note).
    5. Never drop a row without saving the dropped rows to a file and telling me the file name.
    6. Never guess a value. If you cannot convert or map something, list it and ask me.
    Start by confirming the row count of the raw file. Do not clean anything yet.
    A cleaning log table with four steps. Step 1 converts Rs text to numbers, 4,812 rows before and after, 3 failed and listed. Step 2 reads dates as dd-mm-yyyy, range 01-07 to 30-09. Step 3 maps state names, 41 cells, using my table. Step 4 removes exact duplicates, 4,812 rows become 4,775, 37 rows saved to removed.csv. A yellow bar says the raw file never changed and every lost row has a reason and a file.
    One line per step. Rows only go down where you decided they should.
    Why?

    Without a log, a cleaned file is a black box. With one, anyone can see that 37 rows were removed, why, and where they are, and you can undo any step.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Amounts: "Rs 1,24,500" is text, not a number
  2. Dates: tell it the format, never let it guess
  3. State names: a mapping table you approve
  4. Duplicates: a person decides the rule
  5. Recap