Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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!
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
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!
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.