Forum Discussion
Hi philliperamos,
You can use mapKeys and mapValues function to extract the values from the file (the first mapper extracts the Keys, the second mapped extracts the Values), also make sure to unchecked the Columns header option in the CSV parser. Please see attached screenshot and pipeline. Hope this helps.
Regards, Jovan.JJ new pipeline 123_2019_11_06.slp (7.2 KB)
Thanks @jovan.j for the reply/suggestion. I’ll give it a try with my source file.
Use a mapper, pass existing fields through, and create a new field $halfAge = $Age / 2
Sorry for my wrong input structure. the below is the correct one. It is a list of objects rather than 3 single objects
{‘items’:[
{
‘ID’:123,
‘Name’:‘Tony’,
‘Age’:24
},
{
‘ID’:124,
‘Name’:‘Sam’,
‘Age’:36
},
{
‘ID’:125,
‘Name’:‘Glenn’,
‘Age’:58
}]}and the view in mapper is like below:
Can you please process now?
Since you’re manipulating an array, you’ll want to look into the “Mapping Root” feature of the Mapper. By pointing the Mapping Root at your array, the Transformations will be applied to the elements of the array instead of the top-level document. Otherwise, the Mapper configuration is the same as suggested by @christwr:
- cjhoward187 years agoEmployee
sounds like you want to do something like this which you can do using sl.zip()
sl.zip($items, $genderArray).map(pair => pair[0].extend({ Gender: pair[1] }))
Thanks @cjhoward18, @cstewart
It works fine. Thank you
Related Content
- 6 months ago
- 8 months ago