Forum Discussion

arvindnsn's avatar
arvindnsn
Contributor
2 years ago
Solved

Comma Separated String into Rows

  Hello,

   I have a requirement where a text with "," delimiter has to be generated into rows.

 For Example a string or text  $src_name = "AMK, ACK, AGK, ABK" should be generated as following rows.

The output should be separate rows as below.

AMK

ACK

AGK

ABK

I tried using the Group by N with group size set to 0 and then use the expression "group.split(‘,’) " in the mapper following the Group by N as below. I am getting error and not able to find a way to solve this.

Any help is appreciated.

Thanks

Aravind N

 

 

  

  • arvindnsn 

    1) First try to split the string by "," - and as an output you will receive array of records: 

                    ("AMK,ACK,AGK,ABK").split(',')

                   output: ["AMK","ACK","AGK","ABK"]

    2) Then split the array, using JSON Splitter Snap. 

    BR,

    Spiro Taleski

2 Replies

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    arvindnsn 

    1) First try to split the string by "," - and as an output you will receive array of records: 

                    ("AMK,ACK,AGK,ABK").split(',')

                   output: ["AMK","ACK","AGK","ABK"]

    2) Then split the array, using JSON Splitter Snap. 

    BR,

    Spiro Taleski

    • arvindnsn's avatar
      arvindnsn
      Contributor

      This worked well. Thank you.

      Also, Is it possible if this can be achieved in a single mapper expression without using the splitter.