I am using Talend to make an ETL project. To convert my string to Double, i use Float.parseFloat(row4.Exportation2.trim()) This the error that it gives me. This is how my data looks like "766,9997474" "1 345,43" in the exportation2 Does anyone have an idea why ?
Démarrage du job ConvertString a 14:03 27/01/2017.
Exception in component tMap_1
java.lang.NumberFormatException: For input string: "23,4897452"
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at sun.misc.FloatingDecimal.parseDouble(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at last.convertstring_0_1.ConvertString.tFileInputDelimited_1Process(ConvertString.java:1553)
at last.convertstring_0_1.ConvertString.runJobInTOS(ConvertString.java:2075)
at last.convertstring_0_1.ConvertString.main(ConvertString.java:1932)
[statistics] connecting to socket on port 3464
[statistics] connected
6|Royaume-Uni|BA|1971|23,4897452
[statistics] disconnected
Job ConvertString terminé à 14:03 27/01/2017. [Code sortie=1]
Multiple problems here :
"," is not the expected char : it should be "." :
You will have to convert "," char to "." char : if your input comes from an excel or delimited file, you can set this option on the advanced settings of tFileInput component ("advanced separator"). Otherwise you should use yourString.replaceAll(",", "."))
there is a non-standard space in the String that you should replace with yourString.replaceAll(" ", ""))