# Clean a CSV Before You Upload It (or Paste It Into AI)

From Distru's No Bullshit AI Course, modules 03 and 05. A bad import is worse than no import. Two minutes here saves an afternoon later.

## Before you touch anything

- [ ] **Keep the original.** Duplicate the file. Name it `original-YYYY-MM-DD.csv`. Never edit the original.
- [ ] **Know the target.** If this is going into a system (Distru, QuickBooks, Metrc), open that system's import template first. Column names must match it exactly.

## Structure

- [ ] One header row, row 1. No title rows, no blank rows above it.
- [ ] No merged cells. No sub-headers. No totals row at the bottom.
- [ ] One value per cell. "3.5g x 12" is two columns (`weight`, `qty`), not one.
- [ ] Every row has the same number of columns. A stray comma inside a product name breaks this; wrap that cell in quotes or remove the comma.
- [ ] Delete columns you do not need. Fewer columns, fewer mistakes, and cheaper to paste into AI.

## Identifiers

- [ ] IDs and tags are text, not numbers. Spreadsheets turn `000123` into `123` and long tags into `1.23E+23`. Format the column as text *before* pasting data into it.
- [ ] Metrc tags are 24 characters. Check one. If they are 23 or 25, something got trimmed or padded.
- [ ] No leading or trailing spaces in ID columns. Use TRIM.
- [ ] Case is consistent. Tags are usually uppercase.

## Numbers and units

- [ ] Quantities are plain numbers: `453.6`, not `453.6 g` or `453,6` or `$453.60`.
- [ ] One unit per column. If the sheet mixes grams and pounds, add a `unit` column or convert everything to one unit. 1 lb = 453.592 g.
- [ ] No currency symbols or thousands separators in numeric columns.
- [ ] Negative numbers are real negatives (`-12`), not `(12)` or `12-`.

## Dates

- [ ] One format. ISO (`2026-09-16`) is safest and every system reads it.
- [ ] No mixed `MM/DD` and `DD/MM`. If you are not sure which one a column is, find a row with day > 12 and check.
- [ ] No text like `yesterday`, `Q3`, or `next week`.

## Text

- [ ] Product names match the target system's names exactly, or you have a mapping column.
- [ ] No line breaks inside cells unless the cell is quoted.
- [ ] Remove notes to yourself ("check this!!", "??").
- [ ] Encoding is UTF-8. If you see `Ã©` or `â€™`, the file was saved wrong. Re-export.

## Privacy (before pasting into any AI)

- [ ] No customer names, phone numbers, emails, or addresses unless the task truly needs them. Replace with `Customer 1`, `Customer 2`.
- [ ] No employee SSNs, DOBs, or badge numbers. Ever.
- [ ] No API keys, passwords, or license numbers in any cell or header.

## The two-minute check

1. Sort by each ID column. Look at the top and bottom rows for blanks and weird values.
2. Row count before = row count after (unless you meant to delete rows). Write both numbers down.
3. Open the file in a plain text editor. Look at the first three lines. That is what the machine sees.

## Let AI do the boring part (safely)

Paste the header row and three sample rows, then ask:

> "Here is my header and three sample rows. Write me a formula or a short script that [converts all dates to YYYY-MM-DD / strips units from the quantity column / trims spaces from the tag column]. Do not change any values you were not asked to change. Explain how to check that only that column changed."

Then **diff** old vs. new. Only the intended column should differ. If anything else changed, stop.

License: CC0.
