Loading

Keep First '0' When Importing a CSV File

Julkaisupäivä: Dec 2, 2024
Kuvaus

A CSV file will retain leading zeros when opened with text-type apps such as Notepad, Sublime, or TextEdit. However, both Excel and Google Spreadsheet will remove leading zeros after saving the file, unless formatted as described below.

 

This is an Excel/Sheets feature, Salesforce does not control this functionality. Below are steps that can be taken to restore the leading zero in the file so an import into Salesforce has the expected values.

Ratkaisu

When a CSV file has a field that includes a leading zero, it is possible to open the file in a text editor such as Notepad or Sublime to verify the leading zero is present.  Salesforce will then import the file properly.  If the CSV file is opened and saved in Excel, the following steps must be completed in order to retain the leading zero and ensure it is properly imported into Salesforce.

Please note that the steps listed below are just one example of how to use a custom field in Excel to display the leading zero.  For more methods on retaining leading zeros, please visit the Microsoft support page.

Steps to retain initial '0' when importing a CSV into Excel and saving the file:

1. Once you open the CSV file, right-click the column letter and select Format Cells.
2. In the Format Cells window, choose Custom.  Set the format to '00000000' for example to represent a field of length 8.  The number of 0's should indicate the number of characters desired in the field, including the 0's. If the field value is 012345, then the custom format should be '000000' to indicate 6 digits with the 0. 
3. Save the file as a .CSV.

Note: The above steps are just one way to have the leading zeros display in Excel.  These steps need to be implemented every time the CSV file is reopened in a spreadsheet program like Excel.  Opening the CSV with a text editor like Notepad or macOS TextEdit.app will show the leading zeros.

For more information on the different ways to format fields to keep leading zeros in Excel or GoogleSheets, please visit the Microsoft or Google websites for more information.  

Knowledge-artikkelin numero

000387891

 
Ladataan
Salesforce Help | Article