Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

use of globalContext and variable file name in lookups and main flow

Highlighted
One Star

use of globalContext and variable file name in lookups and main flow

We have a job wherein we have to lookup multiple files but the file names are not constant. So I have to iterate thru the main file and get variable part of the file name and use that for lookup files. However when running the job, the lookup files fail coz they seem to processing before I iterate the main file to get the variable extn!

Highlighted
Community Manager

Re: use of globalContext and variable file name in lookups and main flow

Hi
Can you please show us the more details of your job? I think there must be a job design issue. The job looks like:
tfileinput1--main(row1)--tFlowToIterate--iterate--tJava--oncomponentok--tfileinput1--main--tMap--out1--
                                                                                                                              |
                                                                                                                           lookup
                                                                                                                              |
                                                                                                                        tfileinput2
tfileinput1: read the lookup file name from a file and then iterate each one
tJava: store the current lookup file name to a context variable, let's call it context.filename, eg
context.filename= (String)globalMap.get("row1.colName")

tfileinput2: set the file path with context variable, for example:
"d:/file/"+context.filename

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

2019 GARTNER 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

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