Hello aishu,
Create a routine or function to return the string array and use that function in tMap or you can also use this split function in tJavaFlex component to derive new columns.
Hi Aishu,
Could you elaborate your case with an example with input and expected output values? Maybe I can design a demo job with expression in tMap for you .
Best regards
Sabrina
Hi Sabrina,
Source table have 2 fields like
Telephone_1 , Telephone_2.
This 2 fields have data like
Telephone_1 Telephone_2
-------------- ----------------
9999999ext29 88888888ext30
8888888ex30 666666666ext40
My requirement is if Telephone_1,Telepohe_2 contains extension number,
we split Telephone_1,Telephone_2 field data and insert the extension number
data into another fields.
output like
========
Telephone_1 Telephone_1_extension Telephone_2 Telephone_2_extension
--------------- -------------------------- --------------- ---------------------------
9999999 29 888888888 30
8888888 30 666666666 40
I used tExtractdelemitedFields component for this requirement , it is working fine.
source table have 5 fields , so i used 5 times tExtractdelemitedFields component in my job.
Is there any alternate solution?
Hi Sabrina,
Source table have 2 fields like
Telephone_1 , Telephone_2.
This 2 fields have data like
Telephone_1 Telephone_2
-------------- ----------------
9999999ext29 88888888ext30
8888888ex30 666666666ext40
My requirement is if Telephone_1,Telepohe_2 contains extension number,
we split Telephone_1,Telephone_2 field data and insert the extension number
data into another fields.
output like
========
Telephone_1 Telephone_1_extension Telephone_2 Telephone_2_extension
--------------- -------------------------- --------------- ---------------------------
9999999 29 888888888 30
8888888 30 666666666 40
I used tExtractdelemitedFields component for this requirement , it is working fine.
source table have 5 fields like Telephone_1 ,Telephone_2,Telephone_3,Telephone_4
Telephone_5 so i used 5 times tExtractdelemitedFields component in my job.
Is there any alternate solution?
Hello aishu,
You can create a function to split the telephone number and extension. function should return the string array. And then you can use the array to assign the values to required columns using tJavaFlex.
Hi Sabrina,
If Telephone_1 field contains ext,ex.
I replace ext,ex as ';' using tReplace component,
and i used semicolon ';' as a Field Separator in tExtractDelimitedFields.
My job design like:
tpostgresssqlinput----------->tReplace----------->tExtractDelemitedFields---------->tlogrow
Thanks for your replay
Regards
Aishu
To use the .split method, which is what tExtractDelimitedFields uses, you do not need to replace the "ext" and "ex" with ";". It will work fine with "ext?" as the Field Separator. The manual way to use it in an expression would be:
row1.Telephone_1.split("ext?") for the phone number
row1.Telephone_1.split("ext?") for the extension
But when there is no extension, this will cause an ArrayIndexOutOfBoundsException. So you would need code like the following (in tJavaRow):
String[] parsedNumber = input_row.Telephone_1.split("ext?");
output_row.Telephone_1 = parsedNumber;
if (parsedNumber.length>1) {
output_row.Telephone_1_extension = parsedNumber;
} else {
output_row.Telephone_1_extension = null;
}
parsedNumber = input_row.Telephone_2.split("ext?");
output_row.Telephone_2 = parsedNumber;
etc...
It's a bit of a pain to replicate 5 times so you could convert it to a routine instead but since you only ever have at most two values as a result of the split, I would probably just use expressions like:
row1.Telephone_1.replaceAll("ext?\\d+","") for the phone number
row1.Telephone_1.replaceAll("^\\d+(ext?)?","") for the extension, noting that this will be "" not null if there's no extension