How to validate a TMS CSV file before importing freight data
Validate file structure before interpreting freight fields, and validate the interpreted rows before writing records. A well-formed file can still contain shifted columns, ambiguous decimals or duplicate shipments.
Pin the delimiter, encoding, headers and field types.
RFC 4180 describes a commonly used CSV format, including quoted fields. Make the partner’s dialect explicit rather than assuming every export follows it. Use a parser that understands quotes and line breaks inside a field; splitting a line on commas is not sufficient.
Keep source identifiers as strings, and distinguish an empty field from an absent column. Preview the parsed counts and mapping revision before applying changes.
One quoted address should not shift the columns.
A synthetic export has a quoted consignee address containing a comma, a shipment ID with leading zeroes, and a decimal string in a partner-specific format. Verify the address stays in one column, the ID is unchanged and the decimal is interpreted only under the agreed format. Quarantine the row if the chosen source contract cannot resolve it.
Test a rejected row without duplicating valid shipments.
- Layout change: catch duplicate, missing and renamed headers before the file changes stored records.
- Invalid values: identify the affected row and field without echoing sensitive payloads into a shared log.
- Retry: rerun the same file against the same mapping version and verify that already accepted logical records are not created again.