[resolved] How to read the same file twice in a flow ?

One Star

[resolved] How to read the same file twice in a flow ?

I have a scenario in which I need to do the following:
1) Read File A - Based upon some data contained in the file create a record of type "PI01"
2) Read File A (Same File)- Based upon some data contained in the file create a record of type "AL01"
3) merge data of (1) and (2) and create an output XML
When I tried to map it as a Job, for (1) and (2), I used FielName: ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) as per my Job diagram but when I run it,
get a run time exception saying that the (2) cannot get the FileName and is unable to read the record, There is no problem with (1)
Do you know how to achieve this scenario where I have to read the same file again and again, create several types of record and then merge all the records together
Thanks

Accepted Solutions
Community Manager

Re: [resolved] How to read the same file twice in a flow ?

Hello
Put your tFileInputDelimited, tMap, tFileOutputXML component in a child job.
eg:
On father job:
tFileList--iterate-->tRunJob(run the child job)
On child job:
tFileInputDelimited_1-->tmap-->tFileOutputxml
|
tFileInputDelimited_2
Define a context var called filename in child job.
On tRunJob, select the child job, add a parameter: filename on the 'context param' table and set the value as: ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
on tFileInputDelimited_1, tFileInputDelimited_2, set the 'File Name' field with context var: context.filename
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] How to read the same file twice in a flow ?

Hello
Put your tFileInputDelimited, tMap, tFileOutputXML component in a child job.
eg:
On father job:
tFileList--iterate-->tRunJob(run the child job)
On child job:
tFileInputDelimited_1-->tmap-->tFileOutputxml
|
tFileInputDelimited_2
Define a context var called filename in child job.
On tRunJob, select the child job, add a parameter: filename on the 'context param' table and set the value as: ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
on tFileInputDelimited_1, tFileInputDelimited_2, set the 'File Name' field with context var: context.filename
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] How to read the same file twice in a flow ?

thank you shong.. it works...