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
Highlighted
Community Manager

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

View solution in original post


All Replies
Highlighted
Community Manager

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

View solution in original post

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

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 2

Part 2 of a series on Context Variables

Blog

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