Sub topic 2
Preparing your CSV file
A clean CSV file prevents most import errors before they happen. This chapter covers how to build one that both the Data Import Wizard and Data Loader can read. It assumes you know what Salesforce objects, records, and fields are, and that you can edit a CSV in a spreadsheet or text editor.
What a CSV file needs
A CSV (comma-separated values) file is plain text. Each line is one record, and commas separate the values on that line. Both tools expect the same basic shape:
- The first row is a header row. Each header names a column.
- Each later row is one record.
- Every row has the same number of columns as the header.
- The file is saved as CSV, ideally with UTF-8 encoding, so accented and non-Latin characters survive.
Here is a minimal insert file for the Account object:
Name,Phone,Industry,Website
Acme Corp,555-0100,Manufacturing,https://www.acme.example
Globex Ltd,555-0101,Technology,https://www.globex.exampleUse header names you can recognize. Data Loader and the wizard suggest field mappings by comparing headers to field labels and API names. Headers such as Name and Phone map automatically. Headers such as Col1 need manual mapping. The mapping step is covered in a later chapter.
Build the file step by step
- Pick the target object and list the fields you want to fill.
- Check which of those fields are required. A later chapter covers requirements and validation rules in detail.
- Create one column per field, using a clear header.
- Enter one record per row.
- Save as CSV and reopen it in a text editor to confirm what was actually saved.
Step 5 matters because spreadsheets can change data when they save or display it. The text editor shows the real contents.
Common formatting problems
Most failed rows trace back to a few causes.
| Problem | What goes wrong | Fix |
|---|---|---|
| Commas inside values | `Acme, Inc.` splits into two columns | Wrap the value in double quotes: `"Acme, Inc."` |
| Quotes inside values | A stray `"` breaks the row | Double it inside a quoted value: `"The ""Big"" Deal"` |
| Line breaks inside values | The row is split in two | Keep the value quoted, or remove the line break |
| Dates | A spreadsheet reformats `2026-03-04` to a local style | Use a format Salesforce accepts, such as `YYYY-MM-DD`, and check it in a text editor |
| Leading zeros | `00123` becomes `123` | Format the column as text before entering data |
| Long numbers | Large IDs shown as `1.23E+15` | Format the column as text |
| Picklist values | A value not in the picklist is rejected | Match the picklist value exactly |
| Blank rows | Empty lines produce errors or empty records | Delete them before saving |
Excel and similar tools are the usual cause of silent changes. If a value looks right in the spreadsheet but wrong in the text editor, fix the column format and re-enter the value.
Files for updates and deletes
Insert files contain only field values. Update and delete files also need a way to identify the existing records. In Data Loader this is the Id column. Data Loader needs it, and the wizard does not use it for this purpose, so you will normally update through Data Loader.
Id,Phone,Industry
001XXXXXXXXXXXXXXX,555-0199,Energy
001YYYYYYYYYYYYYYY,555-0198,RetailThe IDs above are placeholders. Replace them with real ones. The easiest way to get real IDs is a Data Loader export, which also gives you a backup of the current values:
SELECT Id, Name, Phone, Industry FROM Account WHERE Industry = 'Energy'Edit the exported file, keep Id and the columns you want to change, and use it as your update file.
Check the file before loading
- Open it in a text editor and scan the first and last rows.
- Confirm the row count matches what you expect.
- Run a small test with a few rows before the full load.
- Keep the original export or source file unchanged, and work on a copy.
Exercise
A CSV row contains the value Smith, Jones & Co in the Name column, and the import reports that the row has too many columns. What is the cause, and how do you fix it?
Show answer
The comma inside the value is read as a column separator, so the row has one extra column. Wrap the value in double quotes ("Smith, Jones & Co") so the whole text is treated as a single value.
Exercise
You open an exported file in Excel, and an ID-like column shows 1.23E+15 instead of the full number. What should you do before saving the CSV?
Show answer
Format the column as text and re-enter the original values, because Excel has converted the long number to scientific notation. Then save and check the file in a text editor.