How to iterate flow for each record to generate a file for each record

Six Stars

How to iterate flow for each record to generate a file for each record

Hi all,

I have delimited file in the below mentioned format,

col1~col2~col3~col4
y6211~pot~dog~yellow
y6215~pet~goat~pink
y6220~tap~cow~green

I need to generate a file for each record withe file name as col.txt in the below format
For the 1st record output should be a file with name y6211.txt and content as below
col1=y6211
col2=pot
col3=dog
col4=yellow

For the 2nd record output should be a file with name y6215.txt and content as below
col1=y6215
col2=pet
col3=goat
col4=pink

Like wise i need to generate n file for n records in the input file.


Need some help on this.

Thanks in advance

Regards
Ashok
Community Manager

Re: How to iterate flow for each record to generate a file for each record

Hi Ashok

The following key components are used together to achieve this task:

tFlowToIterate: iterate each input record one by one.
tJavaRow: concatenate all columns to one column.
tNormalize: normalize one row to multiple rows.
tMap: customize the output value base on the line number. 
Var.var1 %4==0?("col4="+row4.conn)Smiley SadVar.var1 %4==1?("col1="+row4.conn)Smiley SadVar.var1 %4==2?("col2="+row4.conn)Smiley Sad"col3="+row4.conn)))

tFileOutputDelimited: set a dynamic file path base on the first column of each record.

For more information, please see the demo job.
demo_job.zip

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: How to iterate flow for each record to generate a file for each record

Hi Shong,

Thank you very much for your quick response.
I will try it out and post u the update.

Regards
Ashok

Re: How to iterate flow for each record to generate a file for each record

hi,
infortune, i canT load the exemple with my ESB 5.3.1r104014 :/
this solution is not very easy, i have 36 fields... imagine the var in txml...

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

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