How to ignore everything after decimal dot?

Highlighted
Four Stars

How to ignore everything after decimal dot?

Hello!

 

I get csvs and one column has an average in a strange format.

 

e.g.  12223.8 or 23422.99999999999

I would like to store 12223 or 23422 instead.

 

How can I remove the dot and everything after?


Accepted Solutions
Six Stars

Re: How to ignore everything after decimal dot?

Hey even I do get in the same format I work in Customer Support Industry for this you just add this

row3.Handle_Time_Total_Seconds.intValue()

 

.intValue() will stop the values after the decimal point

 

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: How to ignore everything after decimal dot?

Convert from float or doubleto int. Should be enough.


TRF
Four Stars

Re: How to ignore everything after decimal dot?

How?

When I try Double.parseDouble(row1.data).intValue()  I get an error.

 

Detail Message: The method parseDouble(String) in the type Double is not applicable for the arguments (Double)

Six Stars

Re: How to ignore everything after decimal dot?

Hey even I do get in the same format I work in Customer Support Industry for this you just add this

row3.Handle_Time_Total_Seconds.intValue()

 

.intValue() will stop the values after the decimal point

 

View solution in original post

Sixteen Stars TRF
Sixteen Stars

Re: How to ignore everything after decimal dot?

If row1.data is a string, then try the following expression:
row1.data.replaceAll("\..*$", "")

TRF
Six Stars

Re: How to ignore everything after decimal dot?

Hi,

 

below code will give you an idea how to remove all character after dot from a decimal value.

Double a = 23422.99999999999;
System.out.println(a.intValue());

String b = "23422.99999999999";
System.out.println((int)Double.parseDouble(b));

You can write the above code in tjava component and run it.

 

--

Please give Kudos and mark topics as solved where appropriate.

Four Stars

Re: How to ignore everything after decimal dot?

I'm new to Talend, but my next project involves a lot of csv imports and I think Talend would be the right tool for it, just need to understand it better.

 

Right now I kinda a bit feel stupid, because nothing seems to work.

Is there something I could do wrong with the csv?

 

tMap always throws an error, even when I say the data in the csv is double and I just want to save it in my DB as double without any cast.

 

Both (input / output) double "can't cast from int to double"

csv double - target int - using your tips "can't cast from string to int"

 

 

 

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 2

Part 2 of a series on Context Variables

Blog

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