Prepare CSV Files

The first row in a CSV file lists the field names for the object that you’re processing. Each subsequent row corresponds to a record in Salesforce. A record consists of a series of fields that are delimited by commas. A CSV file can contain multiple records and constitutes a batch.

All the records in a CSV file must be for the same object. You specify this object in the job associated with the batch. All batches associated with a job must contain records for the same object.

Note the following when processing CSV files with the Bulk API:

  • The Bulk API doesn’t support any delimiter except for a comma.
  • The Bulk API is optimized for processing large sets of data and has a strict format for CSV files. See Valid CSV Record Rows. The easiest way to process CSV files is to enable Bulk API for Data Loader.
  • You must include all required fields when you create a record. You can optionally include any other field for the object.
  • If you’re updating a record, any fields that aren’t defined in the CSV file are ignored during the update.
  • Files must be in UTF-8 format.

To import data from CSV files that don’t meet these rules, map the data fields in the CSV file to Salesforce data fields. See Map Data Fields.

  • Relationship Fields in a Header Row

    Many objects in Salesforce are related to other objects. For example, Account is a parent of Contact. You can add a reference to a related object in a CSV file by representing the relationship in a column header. When you’re processing records in the Bulk API, you use RelationshipName.IndexedFieldName syntax in a CSV column header to describe the relationship between an object and its parent, where RelationshipName is the relationship name of the field and IndexedFieldName is the indexed field name that uniquely identifies the parent record. Use the describeSObjects() call in the API to get the relationshipName property value for a field.

  • Valid CSV Record Rows

    The Bulk API uses a strict format for field values to optimize processing for large sets of data.

  • Sample CSV File

    The CSV sample includes two records for the Contact object. Each record contains six fields. You can include any field for an object that you’re processing. If you use a CSV file to update existing accounts, fields that aren’t defined in the CSV file are ignored during the update. Include all required fields when you create a record.