issue with percentage values

issue with percentage values

hi,
I am getting below error when transferring values in db.
the method replace(string, string, string) in the type String Handling is not applicable for the arguments (integer, string, string) talend
Input is excel, value is 100%. Target column has integer as data type and input has integer as data type.
In expression builder tried StringHandling.EREPLACE(row1.average_rate,"%","0")
Tried tReplace, but still nothing happened.
to explain problem in short,
values for average_rate in excel sheet is in percentage,
100.00%
90.00%
and so on
What output should be is,
100
90 and so on
datatype in database is integer.....
Five Stars

Re: issue with percentage values

If it's telling you that the first parameter you're passing is an integer, then it sounds like you have no "%" character to remove - as it's not a String.
Try using a tLogRow to display the data that is actually coming from your spreadsheet. Maybe there's nothing for you to do?
Four Stars

Re: issue with percentage values

@tal00000 - Agreed...
Else you can do a .toString() before doing the Replace...
Four Stars

Re: issue with percentage values

Hi,
Your input is a string, first replace %--> convert it to float --> convert it to integer as below
output_row.average_rate = (int)(Float.parseFloat(StringHandling.EREPLACE(row1.average_rate,"%","0")));
This will give you output as 100 which is of integer datatype.
Thanks
Vaibhav