How to separate the data from one column into two different fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:35 PM - edited 03-05-2024 10:40 PM
Hi,
I am loading data using transform map and in that their is 1 column in excel sheet called Location.
In that Location column data is written as X,Y(City, State) so while loading the data I want to separate the X in City field and Y in State field. I am not getting how to achieve that. Please help me to understand it. It will be a great help for me.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 01:49 PM - edited 03-06-2024 03:04 PM
Hi, you could use 2 x scripted field maps and string methods to separate out the 'answer' for each target field.
Or you could use a beforeTransform script to deliver same results.
For a field map script, something like this should work (untested).
(edited as script should return a result, not assign it to answer)
var tempSource = source.fieldName.split(',');
return tempSource[0].toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 02:03 PM
Hi @aakankshapl ,
Please create the script like below:
Create field mapping with the following code
answer = (function transformEntry(source) {
var imei = source.u_city.toString().split(',')[0]);
return imei; //Will return city
}
answer = (function transformEntry(source) {
var imei = source.u_city.toString().split(',')[1]);
return imei; //Will return state
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda