[resolved] How can i filter the rows having cost as Zero valure

One Star

[resolved] How can i filter the rows having cost as Zero valure

I am newbie to talend

I upladed a Csv file an di have to filter the rows that have zero cost. how can i filter using tfilterrow.
One Star

Re: [resolved] How can i filter the rows having cost as Zero valure

Welcome to the Talend community! There are some excellent free on-demand webinars on Talend's website that act as a good introduction into how various tasks can be performed. In my opinion, they don't do a very good job of advertising that these are free webinars, and the requirement to provide contact information can certainly act as a deterrent.

http://www.talend.com/webinar/archive/index.php

I believe the webinar titled "Tune data integration processes to handle massive data volumes" shows how to do a basic filter using a tFilterRow component, then how the same filter might be done using a tMap, then how you might use an SQL WHERE clause to perform the same task (which doesn't really apply to a CSV datasource).
One Star

Re: [resolved] How can i filter the rows having cost as Zero valure

Hi andrew in this scenario i have csv file which has zero prices that should be discarded. So i kept the filter "trowfilter" on price column

input_row.SUGGESTED_PRICE.equals(0) then i got the following exception

Exception in component tFilterRow_1
java.lang.NullPointerException
at my1.sanmar_0_1.Sanmar.tFileInputDelimited_2Process(Sanmar.java:8499)
at my1.sanmar_0_1.Sanmar.runJobInTOS(Sanmar.java:9211)
at my1.sanmar_0_1.Sanmar.main(Sanmar.java:9094)
One Star

Re: [resolved] How can i filter the rows having cost as Zero valure

Mahi wrote:
Exception in component tFilterRow_1
java.lang.NullPointerException
at my1.sanmar_0_1.Sanmar.tFileInputDelimited_2Process(Sanmar.java:8499)
at my1.sanmar_0_1.Sanmar.runJobInTOS(Sanmar.java:9211)
at my1.sanmar_0_1.Sanmar.main(Sanmar.java:9094)

It seems that you've run into one of the many gotchas of the Java language. I'm a C/C++/C# guy primarily, so it throws me off every now and then. If SUGGESTED_PRICE is null, you are trying to invoke a method on a null variable, and thus get a null pointer exception. The way I typically deal with this (and would greatly appreciate it if a more Java-oriented individual corrected me if there's a better way) is to check whether the value of SUGGESTED_PRICE equals the value of the fixed number rather than the other way around. In other words:
new Integer(0).equals(input_row.SUGGESTED_PRICE)

This way you're never trying to invoke a method on a null pointer. It seems backwards to me, but it avoids that other pitfall...

EDIT: It also occurs to me that you may want special handling for cases where the suggested price is null. If that's the case, you could also use
input_row.SUGGESTED_PRICE == null || input_row.SUGGESTED_PRICE.equals(0)

Assuming Java bails if the first is true and doesn't attempt to evaluate the second, that should also work.
One Star

Re: [resolved] How can i filter the rows having cost as Zero valure

Thank you for the reply andrew
my schema is a float value so i changed the code to be


[BBCode] new Float(0).equals(input_row.SUGGESTED_PRICE) [/BBCode]
It is working for fine

Thank you very much for your help.
Mahi

2019 GARTNER 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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog