0

I have a text field that can consist of a csv i.e. foo, bar, fizz, buzz.

Using Data Loader, I had an issue where the csv would then think foo, bar, fizz, buzz was being split up into separate columns because of the commas.

I merely wrapped the field into quotes so that it could be seen as 1 column..i.e. "foo, bar, fizz, buzz"

However...the leading and trailing double quotes are actually in the rows in SF.

How can I "escape" these while doing the Data Load? Or - can I use Workbench or something else to write some kinda script and remove the quotes?

Thanks!

3
  • 1
    Alternative approach you might want to consider - in the Dataloader settings, you can choose a different character as your delimiter (we use | characters). Then you shouldn't need the quotes at all. Nov 8, 2021 at 16:41
  • mm...I'd like to retain "," as delimiter bc it's that way for all my other columns. If I could delimit by | for just this column, then I'd like that Nov 8, 2021 at 16:43
  • 1
    How did you edit the file? Have you opened it in a text editor to validate what the file actually looks like?
    – sfdcfox
    Nov 8, 2021 at 18:38

2 Answers 2

2

RFC 4180 specifies how (most) CSVs are encoded. In the file, a cell with ", ,, \r, or \n must be quoted. In other words, "foo, bar, fizz, buzz" should be the correct escape sequence. Make sure that the editor you're using is showing all the characters in the file. I suspect that your actual CSV reads like:

"""foo, bar, fizz, buzz"""

Which, unescaped, equals the value you're seeing:

"foo, bar, fizz, buzz"

Try opening your file in an IDE or Text editor (not MS Word or Excel, for example, but Notepad or VS Code would be fine). If you have the extra quotes in there, you'll want to remove them by replacing """ with "; this should solve your problem.

1

If you find it difficult to can always use .tsv file (tab delimitated file)

1
  • 1
    OP specified in a comment that they would rather not switch delimiters. Nov 8, 2021 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.