Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm new at talend and i'm trying to convert string to float and i facing many issues.
The tConvertType is not working for me, give me this error
For input string: "1,37"
For input string: "1,37"
For input string: "1,37"
For input string: "1,37"
For input string: "1,37"
For input string: "1,37"
For input string: "0,72"
For input string: "0,72"
For input string: "0,72"
For input string: "0,72"
For input string: "0,72"
For input string: "0,72"
For input string: "1.000,72"
Yes, my input data source is a string with "." and ",".
Now, i'm trying with the tMap
using the expression below : Float.parseFloat(StringHandling.EREPLACE(row1.KUS,",","."))
but stil not working
error
Exception in component tMap_2 (Transform_MetaDados)
java.lang.NumberFormatException: multiple points
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1914)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at extract_to_oracledb.transform_metadados_0_1.Transform_MetaDados.tDBInput_2Process(Transform_MetaDados.java:1474)
at extract_to_oracledb.transform_metadados_0_1.Transform_MetaDados.runJobInTOS(Transform_MetaDados.java:2144)
at extract_to_oracledb.transform_metadados_0_1.Transform_MetaDados.main(Transform_MetaDados.java:1994)
Hi,
try this:
Float.parseFloat(StringHandling.EREPLACE(StringHandling.EREPLACE(row1.KUS,"\\.",""),",","\\."))
Regards
Hi,
I'd suggest you do this as a series of steps in the tMap Var section:
1/ String in -> remove the dots (1.000,72) -> (1000,72)
2/ Step 1 String in -> convert the commas to dots (1000,72) -> (1000.72)
3/ Step 2 String in -> parse string to float.
Thanks
hello,
you can try this:-
Float.parseFloat(row1.myString)
thanks,
Warm Regards,
Manish
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 🙂
Hi,
try this:
Float.parseFloat(StringHandling.EREPLACE(StringHandling.EREPLACE(row1.KUS,"\\.",""),",","\\."))
Regards
Hi,
You can use the ternary oparator to check the null or empty row before formatting
try this :
(row2.QTDE_REC_2 != null && !row2.QTDE_REC_2.isEmpty()) ? Float.parseFloat(StringHandling.EREPLACE(StringHandling.EREPLACE(row2.QTDE_REC_2,"\\.",""),",","\\.")): 0
Regards,