Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to load only the values needed using tMap?

I have an sql file which is the source file and a table which is the destination table. The data of the source file is something like:

 

"Refer to mobile# 014-289" and what I only need to load from the source file to  the customer mobile number table is only the number, I should remove this *Refer to mobile#*. Is there anyway to do that using the tmap expression? What is the right syntax/code I should use and it should be done on all the rows, so meaning not only 1 row, there's a row that don't have that *Refer to mobile#* and only mobile number, which is not a problem as there's no modification or anything that is needed.

The tmap looks like the attachment.

 

Thank you in advance for any suggestion or help.

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

    Please use the below code snippet in the tmap and you can parse the telephone number after #. The screen shot of the tmap is as below.

0683p000009Lv8U.png

 

 

The code to be used to parse the value is as below. Please change the name of column from test_ip to the column name of your choice.

 

Relational.ISNULL(row1.test_ip)? row1.test_ip: 
 (row1.test_ip.indexOf('#')<0? row1.test_ip : row1.test_ip.substring(row1.test_ip.indexOf("#") + 2) ) 

If the answer has helped you to resolve the problem, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Hi,

 

    Please use the below code snippet in the tmap and you can parse the telephone number after #. The screen shot of the tmap is as below.

0683p000009Lv8U.png

 

 

The code to be used to parse the value is as below. Please change the name of column from test_ip to the column name of your choice.

 

Relational.ISNULL(row1.test_ip)? row1.test_ip: 
 (row1.test_ip.indexOf('#')<0? row1.test_ip : row1.test_ip.substring(row1.test_ip.indexOf("#") + 2) ) 

If the answer has helped you to resolve the problem, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Yeah, the solution is 100% perfect. Thank you @nthampi 

 

But, I forgot to include that I need to remove the - as well, I'm thinking to use another expression which should be like this?

 

 

 

Relational.ISNULL(row1.test_ip)? row1.test_ip: 
 (row1.test_ip.indexOf('#')<0? row1.test_ip : row1.test_ip.substring(row1.test_ip.indexOf("#") + 2) );
row2.test_ip.replaceAll("\\D", "") 

Is my approach right?

Anonymous
Not applicable
Author

Hi,

 

    You can do it multiple ways in Talend. You can use the current output of current tmap (ie the phone number with hyphen) as the input for another tmap where you can remove the hyphen with a java replace function.

 

    I would suggest you to try it once as an assignment for yourself to strengthen the learning you have achieved till this point.

 

    But if you are stuck at some point, we are always there to help you 🙂

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Hello,

Yeels, I already did, instead of using the Change Function that you gave, I used the replaceAll instead, but still the solution you gave, I can use it on the other part of my tasks.

Thank you!
Anonymous
Not applicable
Author

hi could you explain every point in this expression because i'm getting data aplhanumeric 12a3bcd4 so iwant split this and place in two fields like abcd 1234 so please explain thankyou
Anonymous
Not applicable
Author

Hi Ram,

 

      Below logic has helped me to parse the data.

0683p000009M0kg.png

 0683p000009M0MM.png

 

 

 

The logic to be used is:-

 

Alpha ->                    row1.data.replaceAll("\\P{L}+", "")
Numeric ->                row1.data.replaceAll("[\\D.]", "")

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi