File Writers inside Loop

Hi, I have a directory of files and would like to split them into two new files each. Sometimes the origin files do only contain Dataset A and no Dataset B or vice versa so the result might only be one file from the splitting process in some cases.
→ List Files, Row to Variable Loop Start, Read File, Row Splitter, 2x Empty Table Switches, 2x Write File
How do I close this loop, ensuring all needed (non empty) Writer Nodes do get executed? I tried to connect both writer nodes to a “Merge Variables Node” and this one to a “Variable Loop End” but that fails with “Active Scope End node in inactive branch not allowed
Any help is appreciated, thank you

Hi @fschmid since File Writers do not have any output port, you can use the Variable Loop End.

Just link the 2 File Writers together via the Flow Variable port, and then the last File Writer to the Variable Loop End.

EDIT: Something like this:
image
or like this:
image

6 Likes

Hi @bruno29a thx 4 reply. That’s exactly what I tried but this will fail if one of the writers will not be executed (because of an empty table and Empty Table Switch in front…) !

just found a solution:


using “Variable to Table Row” & “End If” Nodes

1 Like

Hi @fschmid , my example was more to show how to end the loop if you did not have any output data port. Having not seen your workflow, I can’t guess if your File Writer was within the IF or outside. I thought you always wrote to 2 files when you mentioned “2x Write File”.

But ya, if you have an IF node, you gotta close the workflow with an END IF to make sure that you close the Loop after it.

Hello @fschmid,

Case Switch nodes might be useful in these situations as well. For example:

Br,
Ivan

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.