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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to convert a string value of format “$$$$$$$$$$$cc" "0000000001600"?

Hello Talend Community

 

I am new to Talend and JAVA all together.

 

How would I convert a string value of format “$$$$$$$$$$$cc" "0000000001600" for example would convert to string 16.00 with expression builder in a tMap component.

 

I know I can get rid of the starting zeros with StringHandling.RIGHT(“000000000” + row1.amt)

 

I just need to figure out how to add the period so it's 16.00 and if I had an amount of 160.00 in my amt column how would I ensure the 1 wouldn't get trimmed and for 1600.00 I checked that my field and no amount goes over 9999.00. 

 

Any help would be greatly appreciated!!

 

If there is a Java Script Function tool or documentation out there that help me understand the JavaScript expression builder syntax better that would be an added bonus!

 

 

 

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

     You can achieve the functionality by below flow. In the example, I am generating the data but in your case, you will be using input data flow.

0683p000009M1q1.pngdata flow

 

0683p000009M1q6.pngoutput for $160683p000009M1qB.pngOutput for $1600

 0683p000009M1k4.pngtmap output

 

Value for interim_amt_value in Var


row2.amt.replaceFirst("^0+(?!$)", "") 
Value for output_amount

Var.interim_amt_value.substring(0,Var.interim_amt_value.length()-2)+"."+Var.interim_amt_value.substring(Var.interim_amt_value.length()-2) 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Hi,

 

     You can achieve the functionality by below flow. In the example, I am generating the data but in your case, you will be using input data flow.

0683p000009M1q1.pngdata flow

 

0683p000009M1q6.pngoutput for $160683p000009M1qB.pngOutput for $1600

 0683p000009M1k4.pngtmap output

 

Value for interim_amt_value in Var


row2.amt.replaceFirst("^0+(?!$)", "") 
Value for output_amount

Var.interim_amt_value.substring(0,Var.interim_amt_value.length()-2)+"."+Var.interim_amt_value.substring(Var.interim_amt_value.length()-2) 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

Hey Nikhil,

 

Thanks for your knowledge and expertise for this answer that you provided.

 

This worked as expected for my input file.

 

Is there any good documentation that Talend provides on the syntax on manipulating string values. I just want to get familar with the java script language so I can figure these conversions out by myself in the future. Even if the resource book/tutorials cost any money I am willing to pay the fee to learn.

 

Thanks again,

 

Andrew

Anonymous
Not applicable
Author

Hi Andrew,

 

      I am happy to know that it helped to resolve your use case 🙂

 

      At present we are not giving any Java specific training for Talend. The best place where I go for reference is stackoverflow for java related queries. You can good code snippets which you can easily add to tMap and other Talend components.

 

     End of day, Talend is a java code generator. So any properly created java function will work seamlessly in Talend. But if you are stuck somewhere, our  Talend community members are always there to help you 🙂

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂