Skip to content
Data workflows3 min read

By · Editorial policy

Resume a Large CSV Import After a Bad Row

Split the import into bounded chunks, retain each record’s stable identity, and checkpoint only after a chunk commits. Quarantine invalid rows separately so the job can resume without silently dropping records or rereading the entire file.

What is the practical answer?

Split the import into bounded chunks, retain each record’s stable identity, and checkpoint only after a chunk commits. Quarantine invalid rows separately so the job can resume without silently dropping records or rereading the entire file. Pin the source file by version or digest. Assign each parsed record a source ID and a logical row position. A raw byte offset can land inside a quoted multiline field if the parser does not support starting there. A durable checkpoint can instead reference a prepared chunk or a parser-supported logical boundary. If your destination offers transactions, commit chunk results and the checkpoint together when possible. If the systems are separate, use stable row keys so a worker can replay the last chunk. Keep a record of the import ID and parser version so an operator cannot accidentally resume a different file under the original checkpoint.

Evidence: PostgreSQL COPY and CSV format · Reddit enterprise n8n and large-file processing discussion

  1. Pin CSV versionInput
  2. Parse bounded chunksProcess
  3. Apply or quarantine rowsDecision
  4. Resume from committed checkpointRecovery
The import can resume safely because checkpoints describe committed progress in one immutable source file.

Define a stable checkpoint#

What you findWhat to do
CSV format invalid across many rowsstop and inspect the parser or mapping.
One row fails a business rulequarantine that row with its import identity.
Worker exits after committing destination writesrepeat the chunk with stable row keys.

Quarantine rows without losing count#

Record a rejected row’s identity, the validation category, and a controlled reference to the source. Decide which errors permit skipping and which signal a wrong schema or broken parser that should stop the import. At the end, compare the distinct committed and quarantined IDs against expected input IDs. A duplicate or missing record can otherwise hide behind correct-looking totals.

Make row errors operationally actionable#

Keep a rejection record with import ID, source chunk ID, stable record key, rule name, and a controlled link to the input. Use the rejection ledger to distinguish invalid data from transient storage failures. A parsing error that destroys the boundary between records should stop the affected partition rather than guessing where the next row begins.

Let an operator repair a single rejected record under the original import identity. Preserve the rejected version and timestamp and record whose correction produced the accepted version. At completion, reconcile completed and unresolved rows using stable identities. If the destination strips source IDs, maintain a mapping table so resumed imports can still distinguish a previous successful write from an absent record.

Verify it with a failure drill#

Seed a CSV with a multiline field and one invalid row. Interrupt the importer after a committed write but before a separate checkpoint can advance.

  • Restart and verify valid rows appear once, the invalid row is quarantined, and the final reconciliation accounts for every input ID.

Sources and further reading

Official references support technical claims; community discussions are used only as problem signals.