issue with percentage values

issue with percentage values

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,
and so on
What output should be is,
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

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.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.



Introduction to Talend Open Studio for Data Integration.


Downloads and Trials

Test drive Talend's enterprise products.