Four Stars

## Calculating values using Linear Interpolation with two input files using Tmap and tJavaRow

Hello,

I have two input files, one of them is csv and the other one is Excel, they have different schemas.

I tried to use a Tmap to filter and get the columns that I need from both files and put them into two different outputs.

And now I need to do a linear interpolation based on two columns from the first file (csv) and one column from the second file (Excel), I already have the algorithm which requires using a loop and conditions (if, else..).

I don't know if I could do this in the Tmap, or I should use another component.

I found the component tJavaRow but I don't know how to use it because my Tmap has two outputs, would tJavaRow be able to read both of them in order for me to do the linear interpolation ? Is there another solution ?

Thank you.

Moderator

## Re: Calculating values using Linear Interpolation with two input files using Tmap and tJavaRow

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

## Re: Calculating values using Linear Interpolation with two input files using Tmap and tJavaRow

After using a Tmap with the CSV file, I have two columns :

A (pourcentage)

B (duration)

After using a Tmap with the CSV file, I have many columns but the one I need to work with is :

C (duration)

And the one I need to fill is :

D (pourcentage)

For each value in my C column : x , I need to do an linear interpolation to find y (its pourcentage), which means find x1 in B as x > x1 and the next value x2, and their y1 et y2 from column A .

Once I have x1, x2, y1, y2, I can apply this :

y = (y2 - y1) * (x-x1) / (x2 - x1) + y1

## 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 4

Pick up some tips and tricks with Context Variables

Blog

## How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration