Friday, September 27, 2019

Talend ETL - Filtering data based on advanced conditions

Sometimes, we have to filter our source data based on the some advance conditions in the data processing to populate multiple outputs. It is very easy task if you are using Talend Open Studio which has a lot of rich data processing components and you can pass multiple logical conditions as well.

We are here to tell you "How to Filtering data source based on advanced conditions by using tFilterRow?" in Talend Open Studio.

tFilterRow processing component filters input rows by setting one or more conditions on the selected columns. It helps parametrizing filters on the source data. It uses a logical operator to combine simple conditions and to combine the filter results of both modes if any advanced conditions are defined.

Based on the logical operator selected, the conditions are evaluated one after the other in sequential order for each row. When evaluated, each condition returns the Boolean value of true or false.

Input column: Select the column of the schema the function is to be operated on
Function: Select the function on the list
Operator: Select the operator to bind the input column with the value
Value: Type in the filtered value, between quotes if needed.

Warning - In the Value field, you must type in your values between double quotes for all types of values, except for integer values, which do not need quotes.

Example - We want to separate players for "Tennis" and "Cricket" based in Games column as given below:
Id
FirstName
LastName
Games
1
Ryan
Arjun
Baseball
1
Ryan
Arjun
Table Tennis
1
Ryan
Arjun
 Cricket
1
Ryan
Arjun
Tennis
2
Kimmy
Wang
Cricket
2
Kimmy
Wang
Tennis
2
Kimmy
Wang
Basketball
2
Kimmy
Wang
Hockey
3
Rosy
Gray
Badminton
3
Rosy
Gray
 Volleyball
3
Rosy
Gray
Soccer
4
Will
Smith
Tennis
4
Will
Smith
 Basketball
4
Will
Smith
Volleyball
4
Will
Smith
Soccer
5
John
Godson
Swimming
5
John
Godson
 Volleyball
5
John
Godson
Soccer

We will use  tFileInputDelimated, tFilterRow and tLogRow from the Palette onto the design workspace.


Process flow -

  1. On the tFileInputDelimited Basic settings panel, set the filepath to the file to be denormalized and define the Row and Field separators, the Header and other information if required.
  2. Now, connect the tFileInputDelimited to the tLogRow, using a Row > Filter link and rename it as Source Data.
  3. Double-click tFilterRow to display its Basic settings view and define its properties. In the Conditions table, add four conditions and fill in the filtering parameters. From the InputColumn list field of the first row, select Games, from the Function list field, select Lower case, from the Operator list field, select Equals, and in the Value column, type in "tennis".
  4. Now, connect the tFilterRow to the tLogRow, using a Row > Filter link and rename it as Filter.  Then again drop tLogRow from the Palette into the design workspace and rename it as Reject and then again connect the tFilterRow to the reject, using a Row > Reject link.
Final output from Filter tLogRow components - They are in filtered records and rest of them are in rejected records. 
Each rejected record has a corresponding error message that explains the reason of rejection.

To Learn more, please visit our YouTube channel at - 

To Learn more, please visit our Instagram account at -

To Learn more, please visit our twitter account at -

YouTube demo example- 

Wednesday, September 25, 2019

Talend ETL - Combine multiple rows to one comma-separated value

Here you will learn "How to combine multiple rows to one comma-separated value  by using tDenormalize processing component?" in Talend Open Studio.

tDenormalize processing component helps synthesize the input flow means denormalizes the input flow based on one column. This component can be used as intermediate step in a data flow.

This component is reverse of tNormalize processing component. In tNormalize it split records to multiple records .Here in tDenormalize it combine multiple records to single records.
In this example,  we will use tFileInputDelimitedtDenormalizetLogRow from the Palette to the design work-space.

We are using player data and every player plays multiple games and all the games for that player is stored in Games column.
Id
FirstName
LastName
Games
1
Ryan
Arjun
Baseball
1
Ryan
Arjun
Table Tennis
1
Ryan
Arjun
 Cricket
1
Ryan
Arjun
Tennis
2
Kimmy
Wang
Cricket
2
Kimmy
Wang
Tennis
2
Kimmy
Wang
Basketball
2
Kimmy
Wang
Hockey
3
Rosy
Gray
Badminton
3
Rosy
Gray
 Volleyball
3
Rosy
Gray
Soccer
4
Will
Smith
Tennis
4
Will
Smith
 Basketball
4
Will
Smith
Volleyball
4
Will
Smith
Soccer
5
John
Godson
Swimming
5
John
Godson
 Volleyball
5
John
Godson
Soccer
Process flow -
  1. On the tFileInputDelimited Basic settings panel, set the filepath to the file to be denormalized and define the Row and Field separators, the Header and other information if required.
  2. In the tDenormalize component Basic settings, select the columns that contain the repetition. These are the column which are meant to occur multiple times in the document where add as many line to the table as you need using the plus button. Then select the relevant columns in the drop-down list. Select the Merge same value check box to remove the duplicate occurrences.
  3. tLogRow component to show the data on the console.
We want to combine multiple rows from games column to one comma-separated value for each player.
Id
FirstName
LastName
Games
1
Ryan
Arjun
Baseball, Table Tennis, Cricket, Tennis
2
Kimmy
Wang
Cricket, Tennis, Basketball, Hockey
3
Rosy
Gray
Badminton, Volleyball, Soccer
4
Will
Smith
Tennis, Basketball, Volleyball, Soccer
5
John
Godson
Swimming, Volleyball, Soccer

To Learn more, please visit our YouTube channel at - 

To Learn more, please visit our Instagram account at -

To Learn more, please visit our twitter account at -

YouTube demo example- 

Popular Posts