i've got some column in excel with this kind of content :
Col x
345
Yes
34539456
Butter
Result in Knime is :
345.0
Yes
3.4539456E6
Butter
To clean up in KNIME is not a good way, so how to make KNIME understand in thie case that will be string ? or to fix manually the type of column ???? (I already try File reader : beurk !)
I also read in this forum : why not read all xls/xlsx column as string (pure text) ????? => VERY GOOD IDEA !!!!
I have no experience with this reader, but I like to save my data as csv. It's extremly portable and efficient. Excel can export and import it, too. And if something goes wrong with it, a line reader can help, or you can even manipulate it with a simple editor if all else fails. The only drawback is that you have to watch out for special characters in your data. So maybe that's an alternative?
maybe this thread could be of interest for you. Bottom line: currently you might have to resort to snippets. But if you have a lot of energy, you could try to enhance the Number To String Node with formatting options? I think that could be a perfect project for someones first custom node, depending on how complicated the settings should be.
that looks good, but I took the liberty to suggest a few modifications
final String VALUE_ON_ERROR = null; // I'm not sure what this should be. <null>? "0"?
DecimalFormat df = new DecimalFormat("0.###");
String tested = $Col0$; // pet peeve: upper case variable names (unless it's a constant) ;)
// the idea to test for null was good
if (tested == null || tested.trim().isEmpty()) {
return VALUE_ON_ERROR;
}
// the replacement looked unnecessary, as did the startsWith-test
// if you feel the need to include them, make sure the null-test is the first
try {
Double dblReturn = Double.parseDouble(tested);
return df.format(dblReturn);
} catch(NumberFormatException e){
return VALUE_ON_ERROR;
}