Forum Discussion
Hi @spinaka,
I do not understand the “Column mapping data from parameter”. You are sending this array as parameter in the pipeline or something ?
Here is a solution that might help you, if it’s not correct just answer me question above.
My sample data for the expression:
[
{
"ID":1,
"NAME":"testuser",
"Mapping": [
{
"src_col_name": "ID",
"tgt_col_name": "sys_id"
},
{
"src_col_name": "NAME",
"tgt_col_name": "user_name"
}
]
}
]
Expression:
$.mapKeys((value, key) => $Mapping.findIndex(el => el.src_col_name == key) >= 0 ? $Mapping.find(element => element.src_col_name == key).tgt_col_name : key)
Output:
[
{
"sys_id": 1,
"user_name": "testuser"
}
]
Regards.
Viktor
Amazing @viktor_n. I made a little change and your trick worked perfectly. You deserve an award 🙂
I will be using it in my original pipeline to see the same result. Would mind clarifying the “findIndex()” used here?
I transformed the column mapping accordingly. Not an issue.
Hi,
Long time ago, I encountered this also.
If I remember well, it was due to the space in the right path header name.
I don’t remember if you also should remove the space in the left path header but you may want to remove it also.You should use a mapper for each of your csv file and rename this two columns.
Give it a try and let us know!
Related Content
- 2 years ago
- 3 years ago