FileId need to generate for list of files.

Five Stars

FileId need to generate for list of files.

Hi,

 

I am new to talend tool.

 

I am trying to load data into Database table for multiple files with same structure.

So I have used tFileList and Iterate for each file and loaded the files.

But my requirment is load all the files into stage table with Fileid for each files.

 

I am attaching the screenshot for the same.

 

Example :

 

file1.txt

id,name,state,country

011,aa,TX,US

012,bb,NC,US

 

file2.txt

id,name,state,country

123,cc,NY,US

456,dd,CA,US

 

 

Target

fileid,seqno,id,name,state,country.filename

1,1,011,aa,TX,US,file1.txt

1,2,012,bb,NC,US,file1.txt

2,3,123,cc,NY,US,file2.txt

2,4,656,dd,CA,US,file2.txt

 

 

Fileid should be same for all the records if it is coming from same file.

 

Please let me know how can we achieve this in talend? please do needful.

 

Fileid_to_generate.jpg

 

 

 

 

 

 


Accepted Solutions
Sixteen Stars

Re: FileId need to generate for list of files.

This one is simple. When you iterate over files using the tFileList, it keeps track of the number of files currently iterated over. It is stored in the globalMap as tFileList_{number of component}_NB_FILE. You can use this in your tMap.

This post shows you how to find these globalMap values easily....
https://www.talendforge.org/forum/viewtopic.php?id=56425

All Replies
Sixteen Stars

Re: FileId need to generate for list of files.

This one is simple. When you iterate over files using the tFileList, it keeps track of the number of files currently iterated over. It is stored in the globalMap as tFileList_{number of component}_NB_FILE. You can use this in your tMap.

This post shows you how to find these globalMap values easily....
https://www.talendforge.org/forum/viewtopic.php?id=56425
Six Stars

Re: FileId need to generate for list of files.

hi,

 Please find the attachments of desired outputsCapture.PNGCapture2.PNG.

Five Stars

Re: FileId need to generate for list of files.

Thanks Richard!!!

Five Stars

Re: FileId need to generate for list of files.

@kiraninaparty many thanks for your details explanation. it worked as expected Smiley Happy