# Import costs from CSV

> **Important:** Applying a CSV updates a draft only. Reports change only after you save. A matching SKU and effective date replaces that entry in the draft, including its basis and note.

## Before you start

- Open **Costs** in the [dashboard](/dashboard) and use **Cost basis**.
- Prepare costs in the workspace currency, using exact SKU keys from Metryx.
- Keep the file at or below 128 KB and 10,000 data rows. Merged saved history must also stay at or below 10,000 rows.

> **What we do for you:** We can help review the cost setup. You supply the costs, their dates and evidence; the importer does not verify invoices or convert currencies.

## Step 1: Prepare the CSV (about 5 to 15 minutes)

The required columns are `sku,cost_per_unit`. Optional columns are `basis`, `effective_from` and `note`. The parser describes the header shape as `sku,cost_per_unit[,basis][,effective_from][,note]`; do not put those brackets in your file.

Use this exact full header line:

```csv
sku,cost_per_unit,basis,effective_from,note
```

Copy this sample and replace the fictional SKU keys, amounts, dates and notes with your own:

```csv
sku,cost_per_unit,basis,effective_from,note
SAMPLE-SMALL,8.50,estimated,2026-10-01,Initial estimate
SAMPLE-LARGE,12.00,actual,2026-10-01,Supplier invoice checked
```

If `basis` is absent or blank, the cost defaults to `estimated`. Use `actual` only with evidence and a non-empty note. Costs must be finite numbers from 0 through 1,000,000. Do not include currency symbols or thousands separators in an unquoted number.

Dates use valid `YYYY-MM-DD` calendar dates. If you omit the entire `effective_from` column, the import's default date applies to every row. If you include the column, every row needs its own date; a blank cell does not fall back. SKU length is 1 to 180 characters and notes are at most 1,000 characters after trimming. Do not repeat a SKU and date in the same file.

Use double quotes around a field containing a comma or newline, and double an embedded double quote. Each row must have the same number of columns as the header. Headers are trimmed and case-insensitive; unknown or duplicate headers are rejected.

## Step 2: Upload and review (about 2 minutes)

Select **Upload CSV** and choose the file. Review **Default effective date**, initially the report period's start. When your file omits dates, changing this field rebuilds the preview.

A valid preview shows added, changed and unchanged rows. Review the current and proposed amounts, basis, notes and dates. Existing rows with other SKU/date combinations stay in history. If there are invalid rows, fix every error and upload again; no partial import is applied.

## Step 3: Apply and save (about 1 minute)

Select **Apply to draft**, then **Save cost setup**. Applying alone does not persist anything. If the file has no changes, there is nothing to apply. **Dismiss** closes a preview without applying it.

## Verify

**You have unsaved changes** means the draft still needs saving. After saving, check the saved revision and the report-update result. **Cost revision saved; first report pending** confirms the cost save while the first report is still pending. If report refresh fails after a save, use the retry control for that revision; do not assume the cost save failed too.

Check the affected rows in **Cost basis**, including dated history and estimated versus actual status. See [Product costs](/docs/product-costs) for individual edits.

## Troubleshooting

### My file was rejected

These are the exact file-level parser messages and the merge limit message:

| Message | What to fix |
| --- | --- |
| "CSV must be at most 128 KB." | Reduce the file size, including notes. |
| "Invalid CSV quoting." | Put quotes around the whole field, not inside an unquoted value. |
| "Invalid text after quoted field." | Remove text between a closing quote and the next separator. |
| "Unclosed quoted CSV field." | Close the quoted field and escape embedded quotes. |
| "`Use sku,cost_per_unit[,basis][,effective_from][,note] headers.`" | Include required headers and remove unknown or duplicate ones. |
| "Choose an import effective date." | Choose a valid default date when the date column is absent. |
| "CSV must contain at most 10,000 rows." | Reduce data rows. Splitting files does not bypass the merged-history limit. |
| "CSV contains no cost rows." | Add at least one non-blank data row. |
| "Merged cost history exceeds 10,000 rows." | Reduce proposed additions; existing dated history also counts. |

### The preview reports invalid rows

The UI prefixes each row message with its row number. These are the exact parser messages:

| Message | What to fix |
| --- | --- |
| "Column count differs from header" | Match the cell count to the header; quote commas in notes. |
| "Invalid SKU" | Supply a non-empty SKU of at most 180 characters. |
| "Invalid cost" | Supply a finite number from 0 through 1,000,000. Blank is not zero. |
| "Basis must be actual or estimated" | Use actual or estimated, or leave basis blank for estimated. |
| "Invalid effective date" | Supply a real calendar date in YYYY-MM-DD form. |
| "Note exceeds 1,000 characters" | Shorten the note. |
| "Actual costs require a note" | State the evidence or mark the cost estimated. |
| "Duplicate SKU and effective date" | Keep one row for each SKU/date pair in this file. |

The parser reports the first failing check per row. Correct it and preview again to find any remaining errors.

### Another window saved while I was editing

**Your draft is preserved** means the server rejected a stale revision. Review the proposed changes against the latest revision. Unrelated edits from the other window are retained; your edits can replace overlapping entries, so check the comparison carefully.

If loading that revision failed, select **Retry loading latest revision**. Then use **Reapply my edits to latest revision**. This updates the draft only: review it and select **Save cost setup** again. A further conflict requires another review, not a blind overwrite.
