cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping in mapper from file

yash_verma
New Contributor

I have a requirement where i need to map 200 columns from source to target and source and targets names doesn’t match. Also window of mapper component is very small and it is very tedious to map in snap if columns are large. Is there a way that i can create source to target maping in excel and upload to mapper component…

4 REPLIES 4

Supratim
Contributor III

@yash.verma Unfortunately no way to upload any excel in mapper. You can either use auto link property to map automatically based on the source and target system then change the target name accordingly or can select all from source side and drag and drop any filed in mapping expressing text box , it will populate all selected input in mapper but you have to named targeted variable accordingly.

acesario
Contributor II

That sounds like a great enhancement request! What I’ve seen done elsewhere is to use a google sheet or other external file, and call that within your pipeline to get the mappings.

lazo_ilijoski
New Contributor III

Hi everyone,
You may keep mapping file of source and target fields. For instance, if your create the array of mapping among source and target fields (e.g. [sourcefield, targetfield]) as follows:
{
“fields_map”: [
[
“source_field_1”,
“target_1”
],
[
“source_field_2”,
“target_2”
]
]
}

then you can use the following statement in the mapper:
$.mapKeys((value, key) => $fields_map.find(x => x[0].toLowerCase() == key.toLowerCase()) !=null ? $fields_map.find(x => x[0].toLowerCase() == key.toLowerCase())[1] : key)

If you want to have only mapped fields in the output, you can set filtering with mapper snap as follows:
$.filter((value, key) => ($fields_map.length > 0 ? $fields_map.filter(x => x[1].toLowerCase() == key.toLowerCase()).length>0 : true))

$fields_map can be generated by reading values from CSV file and by using one additional mapper snap.

Regards,
Lazo

Sorry to resurrect an old thread, but this is exactly what I want to do, have mappings in a file that is read in (or passed) and then those mappings are used…

It seems from the example that this is possible but I cant work out from the posting how to go about this, if you could expand on how to do this that would be great