Highlighted
Four Stars

## Comparing the first 2 digits of postal code to another colomn

Hello everyone,

I'm a beginner on talend and I will apprecitate if someone can help me with this...

How to match the first 2 digits of a postal code ex: 69000 to another column containing the value 69. Then only show row where these values match. (Excel file with the full data attached)

Example of the data below:

 5 TELMAT INFORMATIQUE 69000 LYON 66 pyrenees-orientales 5 TELMAT INFORMATIQUE 69000 LYON 67 bas-rhin 5 TELMAT INFORMATIQUE 69000 LYON 68 haut-rhin 5 TELMAT INFORMATIQUE 69000 LYON 69 rhone 5 TELMAT INFORMATIQUE 69000 LYON 70 haute-saone 5 TELMAT INFORMATIQUE 69000 LYON 71 saone-et-loire 5 TELMAT INFORMATIQUE 69000 LYON 72 sarthe 5 TELMAT INFORMATIQUE 69000 LYON 73 savoie

Accepted Solutions
Eleven Stars

## Re: Comparing the first 2 digits of postal code to another colomn

But Why your input is cross joined with Region Code ?

Anyways , Try tFilterrow (Use advance Option) with expression ( to check if  col3 starts with Col5 )

StringHandling.INDEX(input_row.col3 + "",input_row.col5 + "") == 0

You could use regex expression also.

Regards
Abhishek KUMAR

All Replies
Sixteen Stars

## Re: Comparing the first 2 digits of postal code to another colomn

If postalCode is defined as an integer, use a tFilterRow to get rows where the values is between 69000 and 69999.
If string, extract first 2 digits first then tFilterRow to get expected result.

TRF
Four Stars

## Re: Comparing the first 2 digits of postal code to another colomn

I don't think you got my question right, please take a look on the attacked excel file file.

The 69000 was just an example, so actually there are several postal codes and several departementIDs that starts with varoius ranges of numbers and characters which needs to be matched, am not sure if tFilterRow can be usful in this case.

Eleven Stars

## Re: Comparing the first 2 digits of postal code to another colomn

But Why your input is cross joined with Region Code ?

Anyways , Try tFilterrow (Use advance Option) with expression ( to check if  col3 starts with Col5 )

StringHandling.INDEX(input_row.col3 + "",input_row.col5 + "") == 0

You could use regex expression also.

Regards
Abhishek KUMAR
Four Stars

## Re: Comparing the first 2 digits of postal code to another colomn

Many thanks Abhishek it works just fine

## OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

## What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

## Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

## Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

## Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog