Talend Replace Data

The Talend Replace data or tReplace field useful to replace a whole word or part of a word in the input rows and returns the output. We can use this Talend tReplace Replace data field to change the wrong type of data etc. In this Replacement data example, we used the Customer table.

Customer Sales Table with HireDate

Talend Replace or tReplace Example

First, drag and drop the DBConnection, DBCommit, and DBInput to establish a SQL Server Connection. Next, we selected the Customers table from the metadata.

Configure Server Connection and write table Select query

Next, drag the Talend tRepalce replace data from the palette to the job design. As you can see from the below tooltip, tReplace replaces an expression with another one.

Talend tReplace to Replace Data

Please connect the DBInput main row to tReplace. Mostly, the input columns will sync with the tReplace. If that is not the case, click on the Sync columns button.

Within the Components tab, there is a simple mode and an advanced mode. You can use advanced mode to write a regular expression. In the Search/Replace section, we have

  • InputColumn: Please select the column you want to use for search and replace.
  • Search: Please provide the search term that you want to search inside the column.
  • Replace with: Write the replacement term in this section.
  • Whole word: If you wish to perform on the entire word or part of a word.
  • Case Sensitive: Do you want to achieve the search in a case sensitive?

Before we perform anything (replace data), click the Edit Schema button to check or alter the Talend tReplace schema as per your requirements.

Edit Schema to Check Columns

Next, click on the Add (plus) button. By default, it adds the first column, i.e., EmpID, and default text.

Add Columns under the Components Tab

Please use the drop-down box to select the required column. Here, we chose the column as Education, Search term as Education, and Replace it with BTech.

Talend tReplace to Replace Data Columns Settings

After finishing the tRepalce Component configuration, we are using the DBOutput to save the Talend replace data output in an SQL Database. Here, we are creating the Talend_repalce table as the destination table.

Configure destination table connections

Let us run the Talend Replace data tReplace Job.

Run the Talend tReplace Replace Data Job

Let me open the Management studio to check the Talend tReplace result.

View Destination Table result

This time, we are using two more fields and running the job. It means Talend tRepalce has to replace the Pro part (not the complete word) in the Occupation field with ABCD and John in the FirstName column with Suresh.

Talend tReplace to Replace Multiple Columns Data

Please check the Talend tReplace result.

View Records

Let me select the Talend Replace field Advanced mode. As you can see, here, we can use the regexp pattern to search the string.

Talend tReplace Advanced Settings to use RegEx to Replace Data