How does everyone handle "," comma within a field in csv file while importing it

Data Loader cannot handle this implicitly because there is no logical path to follow. In case your Data Loader CSV file for import will contain commas for any of the field content, you will have to enclose the contents within double quotation marks " ". Data Loader will be able to handle this.

For example,

Column_1__c,Column_2__c,Column_3__c
AAA,"BBB,CCC",DDD

If you are creating the import CSV in Excel, the quotation marks will be inserted automatically by Excel whenever a comma is detected in any cell - Saving the CSV in Excel and opening the same in Notepad reveals the enclosing quotation marks for cells containing commas.


I'm not sure if you are needing upload & parse the CSV from a custom page, but if you are I have developed the following CSV parser that handles quote-enclosed fields containing commas:

https://gist.github.com/lukemcfarlane/dcd58a2ce703ae4171b7

Tags:

Apex