Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
MDouglas1687874333
Contributor III
Contributor III

Change filename for tFileOutputDelimited in tloop

Hi,

I've got a tloop component and within the loop, I want to write data to a file using tFileOutputDelimited, but i want to dynamically change the name depending on the data. I've tried doing this via a tJavarow but I get a java.io.FileNotFoundException: C:\talend\Talend-Studio-20231027_1100-V8.0.1 error, with C:\talend\Talend-Studio-20231027_1100-V8.0.1 being where talend is installed and not where I want the file to be.

Is it actually possible to do this in the way I want? Or do I have to use a "temporary" file and move the data to the final file(s) outside of the loop?

Part of the loop

MDouglas1687874333_0-1728479605364.png

 

Labels (4)
1 Solution

Accepted Solutions
fcolagiacomo
Contributor III
Contributor III

Hi,

I have the solution in attach:

tFixedFlowInput_2: it produces file names with a placeholder $1

tSetGlobalVar: it substitutes the placeholder with the iteration number and it generates file name to write.

((String)globalMap.get("row3.filename")).replaceAll("\\$1", ((Integer)globalMap.get("tFlowToIterate_1_CURRENT_ITERATION")).toString())

tFixedInput_3: it produces the row to write

tFileOutputDelimited_1: it writes the files.

You have set file name field like this:

"C:/Talend-Studio/studio/workspace_locale/"+((String)globalMap.get("instanceFilename"))

 

 

I hope it is useful for you! 

 

 

View solution in original post

3 Replies
Shicong_Hong
Employee
Employee

Hello

You can set a dynamic output file path based on the input data. Can you show us how do you define the file path on tJavaRow or tFileOutputDelimited?

Regards

Shicong

 

fcolagiacomo
Contributor III
Contributor III

Hi,

I have the solution in attach:

tFixedFlowInput_2: it produces file names with a placeholder $1

tSetGlobalVar: it substitutes the placeholder with the iteration number and it generates file name to write.

((String)globalMap.get("row3.filename")).replaceAll("\\$1", ((Integer)globalMap.get("tFlowToIterate_1_CURRENT_ITERATION")).toString())

tFixedInput_3: it produces the row to write

tFileOutputDelimited_1: it writes the files.

You have set file name field like this:

"C:/Talend-Studio/studio/workspace_locale/"+((String)globalMap.get("instanceFilename"))

 

 

I hope it is useful for you! 

 

 

MDouglas1687874333
Contributor III
Contributor III
Author

Thanks! I managed to use a version of this (tJavarow instead of tSetGlobalVar as I needed to use a few different outputs to set the filename) and it's working now. Turns out I just needed to move the filename setting to before the flowtoiterate as having it after was causing the name to not be set correctly.