Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
slim1501
Contributor II
Contributor II

[resolved] Error in a Tmap : java.lang.NumberFormatException: For input string

Hello,
I have a job that allows you to extract data from Excel and SQL Table to store in a SQL server database.
I did the transformation fields String float.
But I do not understand why I have this error:


Exception in component tMap_2
java.lang.NumberFormatException: For input string: "0,0506609517898527"
Has sun.misc.FloatingDecimal.readJavaFormatString (Unknown Source)
Has java.lang.Float.parseFloat (Unknown Source)
Has bdd_budget_icp.bud_0_1.Bud.tFileInputDelimited_1Process (Bud.java:2332)
Has bdd_budget_icp.bud_0_1.Bud.runJobInTOS (Bud.java:4470)
Has bdd_budget_icp.bud_0_1.Bud.main (Bud.java:4291)
disconnected


Please find enclosed my tmap and my Job.
What is the problem please? and how to solve it?
Regards
Labels (4)
1 Solution

Accepted Solutions
slim1501
Contributor II
Contributor II
Author

The problem was the comma. I resolved; in each column that I want to convert I do this:

fromMainFlow.Tx_RFA! = null && fromMainFlow.Tx_RFA.trim ().length ()> 0? 
BigDecimal.valueOf (Double.valueOf (fromMainFlow.Tx_RFA.replaceAll (",", "."))): null

Thank you all for your help.
See you soon.
have a nice day

View solution in original post

20 Replies
Anonymous
Not applicable

Hi slim1501,

What's your input source data type? How did you set your tMap? Did you set length in schema setting? Could you please upload your tmap editor screenshot into forum?
Best regards
Sabrina
Anonymous
Not applicable

If you replace coma to dot then it will work. see the below statement.
new BigDecimal("0,0506609517898527".replace(",","."))

or you can use below methods to convert it. 
String text = "1,234567";
NumberFormat nf_in = NumberFormat.getNumberInstance(Locale.GERMANY);
double val = nf_in.parse(text).doubleValue();
NumberFormat nf_out = NumberFormat.getNumberInstance(Locale.UK);
nf_out.setMaximumFractionDigits(3);
String output = nf_out.format(val);
slim1501
Contributor II
Contributor II
Author

hello,
My data source is a file (.csv). type columns String.
I set the size to 255 for each column.
enclosed my print-screen.
I tried with Double too, but it does not work
like this:

Relational.ISNULL (fromMainFlow.CST_PROD_KG) == true? null: Double.parseDouble (fromMainFlow.CST_PROD_KG)
 

Exception in component tMap_2
java.lang.NumberFormatException: For input string: "0,05066095178985277"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Double.parseDouble(Unknown Source)
    at bdd_budget_icp.bud_0_1.Bud.tFileInputDelimited_1Process(Bud.java:2345)
    at bdd_budget_icp.bud_0_1.Bud.runJobInTOS(Bud.java:4482)
    at bdd_budget_icp.bud_0_1.Bud.main(Bud.java:4303)

Yours
Anonymous
Not applicable

can you try the solution i provided. I am sure that will work for you.
slim1501
Contributor II
Contributor II
Author

First of all, thank you for your help.
I do not know where to put your code !! Is it in the Tmap (in each destination field)?
Anonymous
Not applicable

My bad, I should explain it in better way. 
so first line of code you can implement it directly in tMap.
new BigDecimal(row1.yourcolumnName.replace(",","."))

but for second solution, you have to create routine and add static method which return BigDecimal value, then write down mention code that can be work. 
slim1501
Contributor II
Contributor II
Author

sorry, I'm a beginner, I could not do it (routine) !! 0683p000009MPcz.png
Anonymous
Not applicable

Below link will help you to do that, but have you tried first solution? and what is the output?
Creating a user routine and call it in a Job
slim1501
Contributor II
Contributor II
Author

I got this error:
Exception in component tMap_2
java.lang.NumberFormatException
Has java.math.BigDecimal. <init> (Unknown Source)
Has java.math.BigDecimal. <init> (Unknown Source)
Has bdd_budget_icp.bud_0_1.Bud.tFileInputDelimited_1Process (Bud.java:3429)
Has bdd_budget_icp.bud_0_1.Bud.runJobInTOS (Bud.java:4067)
Has bdd_budget_icp.bud_0_1.Bud.main (Bud.java:3888)

Do I need to change something my database SQL server data (output)?
CREATE TABLE BUDGET_CA
(current_file varchar(255) PRIMARY KEY NOT NULL,
Date_Bud Date,
code_CLI  varchar(255),
NAT_CODE varchar(255),
code_article varchar(255),
ACTION_BUD2014 varchar(255),
Zone_Geo varchar(255),
Tx_RFA DECIMAL(19,5) ,
CST_PROD_KG DECIMAL(19,5),
CST_LOG_KG DECIMAL(19,5) ,
Kilo_BU DECIMAL(19,5) ,
CA_BUD DECIMAL(19,5) ,
CMA_BUD DECIMAL(19,5) ,
Cpt_Comptbl_F varchar(255),
Code_Analytiques varchar(255)
);
Here join a screen-prints of my CSV file
0683p000009MC0U.png