DEV Community

两只喵的日常
两只喵的日常

Posted on

Why CSV imports fail after cleanup: delimiter, encoding, and mapping checks

CSV import failures are often blamed on the destination tool, but many failures start earlier: the file was cleaned in a spreadsheet, saved with different settings, or mapped into fields that no longer match the target system.

If a CSV opens locally, that does not mean it is import-safe. Spreadsheet apps are forgiving. Importers are usually stricter.

Here is the checklist I use before rerunning a failed CSV upload.

1. Confirm the delimiter

The most basic CSV failure is also the easiest to miss.

A file may be separated by:

  • commas
  • semicolons
  • tabs
  • pipes

If the importer expects commas but the file uses semicolons, the upload may collapse every row into one field. If text fields contain commas without proper quoting, the importer may shift values into the wrong columns.

Before changing field mappings, check whether the row structure is being parsed correctly.

2. Check encoding before editing more rows

Encoding issues usually show up as broken names, symbols, or special characters.

Common signs:

  • accented characters look corrupted
  • currency symbols change
  • names from non-English markets break
  • smart quotes become unreadable
  • imported text does not match the source export

If the data includes names, addresses, product titles, or international text, confirm the export is UTF-8 before rerunning the import.

3. Preserve IDs as text

IDs are not normal numbers.

These values should often stay as text:

Value Risk
000123 leading zeros disappear
2026-001 parsed as a date
C-1042 treated as a category
1E10 interpreted as scientific notation

Once IDs change, it becomes harder to reconcile imported records with the original source.

4. Recheck column mapping after cleanup

Cleanup can change the meaning of a column.

For example:

  • a combined contact field may become separate name and email fields
  • a status column may be normalized into a smaller approved list
  • a company name may need to match a linked record table
  • a date field may be converted into a new format

After cleanup, do not reuse the old mapping blindly. Build a small mapping table:

Source column Target field Field type Cleanup rule
Contact ID Source ID Text Preserve exactly
Company Company Linked record Match primary field
Status Status Single select Normalize values
Created At Created date Date Convert to ISO format

5. Test representative rows, not random rows

The first five rows are not always a good test.

Pick rows that include:

  • one normal record
  • one record with a blank optional field
  • one record with a linked record value
  • one row with date or currency values
  • one row with commas, quotes, or line breaks in text

This catches parsing and mapping issues before they affect the full upload.

6. Keep a post-import review view

After the test import, review:

  • blank required fields
  • duplicate source IDs
  • unexpected select values
  • invalid dates
  • unmatched linked records
  • row counts before and after import

This step matters because some failures are not visible in the upload preview.

I keep a more detailed guide here: CSV encoding and delimiter fix guide

The safest CSV cleanup process is not just about making the file look clean. It is about preserving the values that the destination system depends on.

Top comments (0)