Five Stars

Null Handling while String to Float

I have a column in data source that I am mandated to convert to float. The column contains words so need to replace them empty strings which I am doing as Variable.

row3.Estimated_Sales_Price.replace("REFUSED","").replace("N/A","").equals("") ? null : row3.Estimated_Sales_Price.trim() 

then I am doing,

Var.var2 == null ? null : Float.parseFloat(Var.var2) 

I am getting error: java.lang.NullPointerException. I have tried everything but all have proved to be futile.

Any insights anyone please!!!!!!!!!

  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Seven Stars TRF
Seven Stars

Re: Null Handling while String to Float

Change to
row3.Estimated_Sales_Price == null || row3.Estimated_Sales_Price.replace("REFUSED","").replace("N/A","").equals("") ? null : row3.Estimated_Sales_Price.trim()

TRF
4 REPLIES
Seven Stars TRF
Seven Stars

Re: Null Handling while String to Float

Change to
row3.Estimated_Sales_Price == null || row3.Estimated_Sales_Price.replace("REFUSED","").replace("N/A","").equals("") ? null : row3.Estimated_Sales_Price.trim()

TRF
Five Stars

Re: Null Handling while String to Float

Would love to give you Kudos but the option has been disabled under your post for some odd reason.
Seven Stars TRF
Seven Stars

Re: Null Handling while String to Float

Same on other topic. Kudos are available only for questions, not answers. Sound like a bug.
Come back later Smiley Wink

TRF
Seven Stars TRF
Seven Stars

Re: Null Handling while String to Float

Hi,

Kudos are back :-)

 


TRF