Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] From STRING or INTEGER to float with two decimals

Hello
We receive a delimited text file with one of the field that looks like this :"00000073142"
This field is an amount of money and should be read like 731.42
From this field I have to calculate another one which is 15% of it, here it would be 15% of 731.42 = 109.71
When I declare the discount (15%) field as a Float value, whenever 15% of whatever amount is a sum that end with a 0 (for exemple 31,90), it will be outputed as 31,9
That's not good because I want to print this field and need it to looks like a price, with two decimals.
How can I say inside a tMap component that a float value must have two decimals, no more no less.
I have tried the precision at two but it doesn't look like my answer.
Here and there, I have found the I could use some java code (decimalformat or math.round)
Problem is I don't know how the call this java code inside tMap. It seems I should create a routine than call it from tMap, but I don't know how to do this.
Is the any to do this ?
Thanks a lot
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,
If you have few operations to be called on each row and column, then I would ask you to use tJavaRow before tMap and do processing as required...
Use Ctrl+Space, this will invoke all the existing functions and you can write your own with the help of Java code.
Thanks
vaibhav

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Hi,
If you have few operations to be called on each row and column, then I would ask you to use tJavaRow before tMap and do processing as required...
Use Ctrl+Space, this will invoke all the existing functions and you can write your own with the help of Java code.
Thanks
vaibhav
Anonymous
Not applicable
Author

Hi
Sorry for this late feedback, I had to fly away for some days...
Anyway, thanks a lot for your help.