Talend Tutorial8 Using Condition Based Filters

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Talend Tutorial Task Aid >

Using Condition-Based Filters

This tutorial uses Talend Open Studio Data Integration version 6

1. Create a new Job and add a tMap component


a. In a new Job, add the movies metadata file as input delimited component.
b. Add a tMap component to create new filters.
c. Create a flow of data from the movies component to the tMap_1 component by linking
the two components and rename the link as movies.

2. Add a filter to select only movies that were released in 1990 or


later
a. To create a new output, double-click the tMap_1 component and in the output section of
the tMap wizard, click the [+] button and name the output as moviesFromThe90s.
b. Select all columns from the input movies, drag, and drop them to the output
moviesFromThe90s output.
c. To create a new condition-based filter, click the Activate Expression Filter icon.
d. To create a filter condition, click the releaseYear column and drop it on the expression
filter field, and type >=1990.

3. Store the result in a file


a. Add a tFileOutputXML component to the Job.
b. Link the Row > moviesFromThe90s output to the tFileOutputXML_1 component. Rename
the tFileOutputXML_1 component movies>=1990.
c. To configure the movies >= 1990 component, in the Component view of the component,
specify the path and name for the output file.
d. To rename the root document, in the Row tag field, type movies and run the Job.
e. To check the moviesFromThe90s.xml file, navigate to the folder in which the file was
created and open the file.
The file with the list of movies released in or after 1990 will be displayed.

Talend takes the complexity out of integration


Based on open source Scalable Future-proof Predictable cost
Visit www.talend.com Follow us on Twitter @Talend
Talend Tutorial Task Aid >

4. Create a second filter using two conditions


a. Create a second filter that will filter movies from the 80s only.
Condition filters follow the Java syntax rules. You can easily create a double condition by using
the java && operator (AND).
b. Run the Job.
The file with the list of movies released from 1980 to 1989 will be displayed.

5. Create a filter reject output


a. To create a third filter, in the tMap_1 interface, add another output named
moviesBefore80s and add all columns from the input movies to it.
b. To create a filter reject output, click the tMap Settings icon.
c. Click the [] in the value field of Catch output reject property and click true.
This will collect all rows of data which do not match either of the other two conditions.
d. Add a tFileOutputXML component named movies<1980, and link the moviesBefore80s row
from tMap_1 to it.
e. To configure the movies<1980 component, in the Component view, specify the path and
name for the output file.
f. Run the Job.
g. To check the filterRejects.xml file, navigate to the folder in which the file was created and
open it.
The file with the list of movies released before 1980 will be displayed.

Talend takes the complexity out of integration


Based on open source Scalable Future-proof Predictable cost
Visit www.talend.com Follow us on Twitter @Talend

You might also like