PoolByte

CSV Imports: Preview, Mapping and Error Reports

· PoolByte Technology

CSV Imports: Preview, Mapping and Error Reports

CSV import allows you to quickly move thousands of products or other operational records into the system. Conversely, a single incorrect column match can corrupt many records at once. A good import tool shows you how to interpret the data before reading the file, creating a traceable process.

Make separator and character encoding visible

Don't assume CSV files are always comma separated. Regional tools may produce different delimiters. Separators or line breaks within quotes also cannot be handled safely by simply splitting the text. RFC 4180 defines the basic rules of the common CSV format; actual file types still require preview.

Show in the first few records whether Turkish characters are corrupted or not. Product codes with leading zeros, phone-like values, and long IDs must be preserved as text. Instead of notifying the user later that “00124” will change to “124,” make this difference visible before import. Also have the date and decimal number format explicitly selected.

Column matching is a confirmation step

It should be understood whether the "price" column in the file corresponds to the sales price or cost in the system. The process should not start if the required columns are not present. If an update is to be made, determine the record matching key: it can be the product code, external system ID, or another fixed field. It is not reliable to update based on name similarity alone.

Show separately the number of records to be added, changed and rejected on the preview screen. A test run can produce this result without writing to real data. If the final file changes, the approval of the previous preview should not be considered valid. The import ID and file hash help track what data has been approved.

Evaluate formula-like cells

If the CSV is later opened in spreadsheet software, some cells may be interpreted as formulas. This risk must be addressed not only in import but also in export. OWASP CSV Injection description explains the context of this risk. Quoting the cell does not guarantee safe text for every consumer.

Apply different rules to free text, such as a product description, and the number field that will enter the calculation. Don't silently convert erroneous data to zero or today's date. The report should enable the user to correct the file, with line number and reason information; It is not necessary to dump the contents of the entire file into the error log.

How do you resume an interrupted import?

If you are running the process in small batches, avoid duplication of the same batch creating a double product. Track successful and unsuccessful lines separately. Don't assume that every import is completely reversible; Determine in advance which fields' previous values ​​will be retained. Real user edits made later should not be overwritten during rollback.

Try it first with a file that is small, representative, and contains intentional errors. Different currency formats, blank required fields and duplicate IDs should be present in this file. In the delivery of E-commerce project, the CSV tool should not be completed just because it "accepts files"; It should be understandable which records were changed and why.