Parse Double

Six Stars

Parse Double

Im currently doing a job with 2 tFileInputExcel and joining them with TMAP.

Im getting stuck in the values parsing

 

In my XLS file i got values such as 

                      2.382,35
                           30,25
                           61,61

When i use tLogRow to see that data

2382,349999999999 |
30,249999999999993 |
61,60999999999999 |

 

First i need to replace the "," to "." to convert this String to Double

When i make that some numbers appears correctly as 

2317.35

and others still the same formation 

2382.349999999999

 

Then im getting Null Exception and trying to Double.parseDouble(Variable)

java.lang.NullPointerException

 

I need to numbers be with 00.00 (Only 2 decimal places, can be rounded)

 

There is a way to check with the field "Value" is number to be possible to convert to Double? I think im getting some trash in this process, maybe a alpha that cant be transformed to double.

like (if is a number do convert, if not ignore)

Can someone help me?

image.pngimage.png


Accepted Solutions
Employee

Re: Parse Double

Hi,

 

   I was able to do the same. Please refer the details below.

image.png

 

image.png

 

image.png

 

row1.data.replaceAll("\\.","").replaceAll(",",".")

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 


All Replies
Employee

Re: Parse Double

Hi,

 

   I was able to do the same. Please refer the details below.

image.png

 

image.png

 

image.png

 

row1.data.replaceAll("\\.","").replaceAll(",",".")

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

Six Stars

Re: Parse Double

Thanks for your repply i will try it, but i found a error in my input XLS, somehow the lines after the content has some invalid data, i cleared all the stuff and works perfectly using my way, but thanks for your repply i will try it too, i think is better
Employee

Re: Parse Double

Perfect!

 

Please spare a second to mark the topic as resolved as it will help others also.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Six Stars

Re: Parse Double

I mark this on my tFileInput too, to avoid this stuff later

 

image.png

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog