talend take out zeros before the comma
I have a file with two columns the first one with a name and the second one with a number.
The size of the number column is 20 chars, the numbers use to be less than 2 chars size the rest of the chars are c开发者_Go百科omplite with 0.
I need to take out all the zeros before the comma. I should use a tMap, How?
The solution: Using a tMap, put a Var in the midle of both files (Input and output). In the var use:
"0"+row1.numberField.split(",")[0].replace("0", "") + "." + row1.numberField.split(",")[1]
Example: 000000001,58 Result: 01.58
Solution 2: Define your own routine:
public static String calcImp(String theNumber) {
Float theFNumber = new Float(theNumber.replace(",", "."));
return Float.toString(theFNumber).replace(".", ",");
}
Example: 000000001,587 Result: 1,587
精彩评论