Forum Discussion
Hi Team, I want to normalize the data like below source
col1;col2
ABC;CC1,CC2,CC3
DEF;CC1,CC2,CC3
Target should be like below
col1;col2
ABC;CC1
ABC;CC2
ABC;CC3
DEF;CC1
DEF;CC2
DEF;CC3
May i know how it is possible in Snaplogic?
Hi,
You can use the below expression a mapper followed by a splitter snap.
$value.split(“;”)[1].split(“,”).map(x =>$value.split(“;”)[0]+“;”+x)
in the above expression, $value is assumed to be the actual source value.
The example source json is as follows.
[{“value”:“col1;col2”},
{“value”:“ABC;CC1,CC2,CC3”},
{“value”:“DEF;CC1,CC2,CC3”}]
- dipanjan_pan5 years agoNew Contributor
Thanks a lot @viktor_n …it works
Hi Dipanjan,
You can use the string method charCodeAt
e,g
($Column1.toLowerCase().charCodeAt(0) - 97) + 1
I’m not understanding your example. If Column 2 is supposed to be your rownum() value, why wouldn’t the values be 1, 2, 3, 4, 5 instead of 1, 1, 1, 2, 3?
- dipanjan_pan5 years agoNew Contributor
rownum based on some partition by column. In this case I want the output based on column 1. thats why it is 1,1,1,2,3
Related Content
- 3 years ago
- 8 years ago
- 2 years ago