One Star

Decimal nuber format

Hi everyone,
I am having problem to convert number which is taken from excel as string and during my mapping I have converted to Big decimal as need it to get rid of commas ...
On the end when I am outputting this value in my xml I am having number in format 1.197803E+7.
I had try to change again to string and make to be as normal number using this method but still not have any luck.
out1.Value.toString().contains(".") ? out1.Value.toString() : out1.Value.toString() + ".000000000001"
Is anyone know the easy way to get real number or method how I will do this.
Thanks
Zeljka
8 REPLIES
Community Manager

Re: Decimal nuber format

Hi
What's the real value looks like in excel? What's your expected result? Do you check the box 'read real values from number' in the advanced settings tab of tFileInputExcel.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Decimal nuber format

You should dump the value directly to the console (in tJavaRow e.g.: System.out.println(out1.Value)Smiley Wink to see exactly what it looks like with different conversions applied so you can determine exactly where the problem is.
One Star

Re: Decimal nuber format

If your output File XML defines the target field as a string or double column, try switching it to BigDecimal.
One Star

Re: Decimal nuber format

I have tried to use as string, double and BigDecimal and output is always same ...
I am bit confused now what can be...
Zeljka
One Star

Re: Decimal nuber format

hi everyone,
I have found solution after trying a few things , not sure how briliant is but working at the moment and giving me right output...
new java.text.DecimalFormat("#.############").format(row8.Value.doubleValue())
Zeljka
One Star

Re: Decimal nuber format

Hi
try to read the column as string and then convert to double or float
One Star

Re: Decimal nuber format

Hi,
If you're having trouble with format and applying conversions throughout your map, consider isolating the conversions using this strategy.
1. Set all of the input Excel fields to "string".
2. Create a File XML with specific types (double, BigDecimal) in the XML output fields.
3. Add a tConvertType, preferably with "Auto Cast", to the input Excel to set the Excel types. Leave "uncastable" values as strings. This step will define a second schema based on the input Excel, but with types.
4. Connect a tMap to apply more complicated conversions that may involve a helper function (TalendDate, etc.). Convert any "uncastable" values in the mapping.
The following link is on working with commas and decimal points in numeric strings.
http://bekwam.blogspot.com/2011/05/different-locales-us-europe-in-talend.html
-Carl
One Star

Re: Decimal nuber format

thanks for this tips ...
Z