Start with an input contract
Write down which fields identify a record and which fields are merely supporting evidence. Preserve the original row ID throughout the workflow. Never use the spreadsheet row number as the only identity across different exports.
An account-domain workflow does not need the same required fields as a person-to-email workflow. Inspect the selected action or Play before making fields mandatory. A missing phone number is not a file error when finding that phone number is the job.
Parse CSV as CSV
Use a CSV parser that handles quoted commas, embedded line breaks and escaped quotes. Splitting a line on commas can turn one person’s company name into several columns. RFC 4180 documents common CSV conventions, including quoted fields and a consistent number of fields per record. Reject duplicate headers: two columns both calledemail create an ambiguous mapping. Decide how to handle a byte-order mark, blank lines and encoding before a recurring import runs. Keep the original file intact and produce a separate normalized file.
This illustrative input includes a quoted company name and a duplicate source identity:
Separate file failures from row failures
A missing required header should fail the whole import. One invalid address can go to an exception file while independent valid rows proceed, if partial processing is part of the contract. Give every row exactly one terminal disposition.
Reconcile the counts: input rows must equal accepted, rejected, review and retryable-error rows combined. Report counts for each reason code, such as
duplicate_source_id or unresolved_crm_id. A blank output cell should never be the only indication that processing failed.
Worked import: five rows, one accepted
Assume this example import requires a uniquesource_record_id and a company domain. Phone is optional. The domains and records below are fictional; the rules are specific to this example.
lead-102 before seeing the second would miss the conflict.
The accepted file contains only lead-101. Its empty phone field is allowed. The exception file is:
input_record is a locator within this file revision, counting data records after the header; it is not a persistent identity or a physical line number. Quoted multiline fields can span several lines. Keep both this locator and the source ID so the owner can repair either duplicate.
The reconciliation is 5 input = 1 accepted + 2 review + 2 rejected + 0 retryable errors. Resolving the duplicate means correcting the source identity or explicitly merging the records; deleting an arbitrary duplicate is not a repair.