Forum Discussion

arvindnsn's avatar
arvindnsn
Contributor
3 years ago
Solved

Add single quotes in comma separated string

Hello,

I have a scenario where the location name will come in 2 different scenarios from an API as mentioned below.

  1. LOC1
  2. LOC1, LOC2, LOC3

The expected output should be

  1. ‘LOC1’
  2. ‘LOC1’, ‘LOC2’, ‘LOC3’

I tried using the split and replace function but in vain. Appreciate any help provided here

Thanks
Aravind N

8 Replies

    • arvindnsn's avatar
      arvindnsn
      Contributor

      Good to know using the simple join function to achieve the output. Thank you!!

    • arvindnsn's avatar
      arvindnsn
      Contributor

      This worked perfect. I was trying something with the map function but was missing something. Thanks for the solution.

  • darshthakkar's avatar
    darshthakkar
    Valued Contributor

    I used a simple conditional statement in my mapper like below:

    $field002!=""?" ' "+$field002+ " ' ":""

    You might have to tweak a bit if you’re expecting multiple values in your second stream.

  • darshthakkar's avatar
    darshthakkar
    Valued Contributor

    Yes, multiple ways to achieve the desired output. Some cover all use cases and some won’t. If you have an edge case scenario, that will need a custom formula.

    • arvindnsn's avatar
      arvindnsn
      Contributor

      Yes, Correct. Thank you for the suggestion and input!!