Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
There's a simple job below:
Here is my input csv:
My Tmap in details:
Condition1 is working well which remove space and replace comma with dot and null to "0:
row1.newColumn1==null | row1.newColumn1.equals("")?"0": row1.newColumn1.contains(",")?row1.newColumn1.replace(",", "."): row1.newColumn1.contains(" ")?row1.newColumn1.replace(" ", ""): row1.newColumn1
Condition2 is working well too (same as condition one)
row1.newColumn2==null | row1.newColumn2.equals("")?"0": row1.newColumn2.contains(",")?row1.newColumn2.replace(",", "."): row1.newColumn2.contains(" ")?row1.newColumn2.replace(" ", ""): row1.newColumn2
Condition3: ERROR found: (Trying to keep value to two decimal place and of type string)
String.format("%.5f", (Double.parseDouble(Var.var1) - Double.parseDouble(Var.var2)))
Tried hard but couldn't identify the issue.
Can you advice please?
Thank you very much.
@asadasing,can you re-write cloumn1 and cloumn2,variable expressions as below.should work if you have space issue.
row3.newColumn2==null | row3.newColumn2.equals("")?"0"row3.newColumn2.replace(",",".")).replace(" ","")
@asadasing,cant you try to convet to Float instead of Double,your issue will be resloved.
example:-
Float.parseFloat()
The solution you provided is not working.
I have tried to convert using float and encountering same error.
Float.valueOf(String)
And also
Float.parseFloat(String)
Can you advice please?
@asadasing,your have space or tab between 1 and 4 of 1 430.76. becuase of the your were getting error,you nee to replace that with empty.
@asadasing,can you re-write cloumn1 and cloumn2,variable expressions as below.should work if you have space issue.
row3.newColumn2==null | row3.newColumn2.equals("")?"0"row3.newColumn2.replace(",",".")).replace(" ","")
This one works fine.
Indeed the contain function (.contain) was not working OR it could not recognize the space in the string.
Thank you very much. Issue marked as solved.
Best regards,
asadasing