Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
oasis2000
Contributor II
Contributor II

how to create a file from each row with dynamic name based in columns value for each row

Hi,

I have this flow:

tDBInput - tmap - tflowtoiterate - tfixedinput - tfileoutputdelimited

At the beginning i have a "table" with 3 columns: col1, col2, col3. In the tmap i keep col3 and i create another col (fichName) as col1 + col2. What i want at the end is to have one file for each row and name fichName. Example:

if i had only 1 row in the first table i want to get only 1 file which content is the value of col3 for that only row and the name of that file should be

fichName (

col1 + col2)

I have tried with this flow for a lot of time, also with tsetglobalvar and i dont get the correct result. The closer i got was to have a file for each row containing the value of col3 as desired but the names of those files were null0, null1, null2, etc or simply 0, 1, 2, ...

Can you help me please?

Thanx in advance!

Thanx!

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

on tFlowToIterate, use the default the key,value in global variables, in this case, you don't need to use context variable.

Set the file path like:

"D:/file/"+(String)globalMap.get("out1.nomFich")+".csv"

on tFileOutputDelimited, uncheck the 'split the output in several files' box, you have used tFlowToIterate to iterate each row and set a dynamic file name. If you need a sequence id to be added to the file name, you can generate the sequence id on tMap and concatenate it to the file name

0695b00000RhllXAAR.png 

 

 

 

View solution in original post

6 Replies
Anonymous
Not applicable

Hi @Beatriz Martinez Serna​,

 

Would you mind showing us your job (a screenshot)? Also include screenshots of your file component's config. It looks like the right flow, I suspect that there is a slight config error. It looks like you are nearly there.

Anonymous
Not applicable

To use the current column value in the file name, the expression looks like below, eg:

"D:/file/"+(String)globalMap.get("out1.fichName")+".txt"

//out1 is the flow name after tMap.

 

Regards

Shong

oasis2000
Contributor II
Contributor II
Author

Thanx, I think the problem is in the tFixedFlowInput. I have tried both keeping and not keeping "nombFich" and nothing. Now as i dont really know what i am doing, with the flow as it is, i only get only file again, not one per row as desired :'(

 

0695b00000RhlKvAAJ.png0695b00000RhlL5AAJ.png 

0695b00000RhlLFAAZ.png0695b00000RhlLoAAJ.png 

0695b00000RhlLtAAJ.png0695b00000RhlMDAAZ.png

oasis2000
Contributor II
Contributor II
Author

I tried that, but it didnt work either. Thanx anyway

Anonymous
Not applicable

on tFlowToIterate, use the default the key,value in global variables, in this case, you don't need to use context variable.

Set the file path like:

"D:/file/"+(String)globalMap.get("out1.nomFich")+".csv"

on tFileOutputDelimited, uncheck the 'split the output in several files' box, you have used tFlowToIterate to iterate each row and set a dynamic file name. If you need a sequence id to be added to the file name, you can generate the sequence id on tMap and concatenate it to the file name

0695b00000RhllXAAR.png 

 

 

 

oasis2000
Contributor II
Contributor II
Author

Thanx a lot!! It made the trick!! 🙂