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

  • I am trying to import a csv file and parse the csv file. I have the code working fine, except where we have a "," within a field in the csv.

    While reading the csv its considering the comma as the field delimiter as it should. How do data loaders handle this?

  • Shumon Saha

    Shumon Saha Correct answer

    8 years ago

    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.

    You can actually read the spec on the CSV file format at http://tools.ietf.org/html/rfc4180#page-2 it's only a handful of points and is well worth the read.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM