Issue in Expression Editor

Six Stars

Issue in Expression Editor

Hello Community,

 

I have used the below logic to convert String datatype to Float inside Expression Builder of tMap - 

(row36.Spillover_km3 == null || row36.Spillover_km3.isEmpty() == true)?0  :Float.valueOf(row36.Spillover_km3) 

but I'm getting the below error - 

Exception in component tMap_13 
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

 

Can anyone please let me know how to rectify this issue?

 

For reference I have attached the job screenshot.

 

Thanks in advance!

 

Best Regards.


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Issue in Expression Editor

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)


TRF

All Replies
Forteen Stars

Re: Issue in Expression Editor

@dipanjan93,

can you try the below one.

 

(row36.Spillover_km3 == null || ("").equals(row36.Spillover_km3))?0  :Float.valueOf(row36.Spillover_km3) 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Six Stars

Re: Issue in Expression Editor

Hi @manodwhb

 

I have tried your approach but the issue still persists. 

Fifteen Stars TRF
Fifteen Stars

Re: Issue in Expression Editor

What about this one:

(row36.Spillover_km3 == null || 
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)

TRF
Forteen Stars

Re: Issue in Expression Editor

@dipanjan93,since you might have space issue use the below way.i have tested below one working as expected.

 

 

(row1.Col == null || ("").equals(StringHandling.TRIM(row1.Col)))?0  :Float.valueOf(row1.Col) 

 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Six Stars

Re: Issue in Expression Editor

Hi @TRF

 

Nope still the issue persists. Although now something new has come up -

 

java.lang.NumberFormatException: For input string: "null"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

Fifteen Stars TRF
Fifteen Stars

Re: Issue in Expression Editor

The field contains the string "null" (4 characters). Write line this:
(row36.Spillover_km3 == null || ("null").equalsIgnoreCase(row36.Spillover_km3 ||
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)

TRF
Fifteen Stars TRF
Fifteen Stars

Re: Issue in Expression Editor

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)


TRF
Six Stars

Re: Issue in Expression Editor

Many Thanks @TRF and @manodwhb for your prompt response! It solved the issue.

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download