Setting up context variable for tForEach Component

One Star

Setting up context variable for tForEach Component

I have a tForEach component as a part of my talend project, which iterates a particular transformation for different states of a country. I want to set up the list of these states as a context variable so that each time I want to use a set of different combinations of the number of states. Is this possible?
Ex: I have 10 states in the tForEach component. For testing purpose, I want to use only 3 states to be processed. If it is not a context variable, everytime the list of states in the component needs to be updated on the job and re exported. I do not want to do that each time. Rather, I would like to set the list as a part of contexts and update the list according to requirement.
One Star

Re: Setting up context variable for tForEach Component

Hi
The code of tForEach is as seen below.
Object[] values_tForeach_1 = new Object[] { "newLine", };
for (Object tmp_tForeach_1 : values_tForeach_1)

I don't think you can use a context variable here which contains 10 or 3 states name.
Regards,
Pedro
Community Manager

Re: Setting up context variable for tForEach Component

Hi
Maybe you don't need tForEach component, you can set the value of context variable with more states delimited by a syntax, for example, "state1,state2,state3,state4", and then use a tNormalize component to normalize the column to more columns with item separator "," for example,
state1,state2,state3,state4
becomes
state1
state2
state3
state4
and then, iterate each row. The job design looks like:
tFixedFlowInput--main--tNormalize--main--tFlowToIterate--iterate--the rest of the job.
on tFixedFlowInput, add one column let's call it "states", set its value with context variable.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Setting up context variable for tForEach Component

Thanks Pedro and Shong.
@ Shong:
I will try doing as said. So, all I need to do here is not to disturb any other existing component, but set up a context variable for how many ever states I want to use and replace tForEach with a tNormalize component and set up the column name to be normalized with item separator ",". Is that right?
One quick clarification: Does this column name that we use in "Column to normalize" has to do with any particular field of a database table or how and where do we initialize/declare and map that column name to?
Thanks

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

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

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog