Hi,
Within a workflow I have two branches that get executed one after another (Block until done). Each branch generates a CSV file at the end and separate from the other branch. The requirement is to make sure either both files get generated or none of them (In case one of the branches fail for database access etc.)
I was thinking to use a batch file to search the destination folder once both branches complete and if any of the files are missing delete the other file, but I’m wondering if there is better way to handle this perhaps using one of the Alteryx tools.
Thanks,
Solved! Go to Solution.
Thank you for the reply.
I've attached a snapshot of my workflow. As you see there I have two separate branches and each of them generate the output file separately. When I generate the first extract I cannot count the number of records in the second branch because second branch hasn't started yet so I'm not really clear how counting records can be used in this scenario.
Thanks,
Hey @HA,
As @ThizViz mentioned, you can do this in different ways if you're thinking about the zero-row issue (in other words - only write the files if there's more than 0 rows in each file).
Options I can think of are:
- Instead of writing them to file at the end of each branch of the workflow; you can write them to a database (or Alteryx file), and then in the next workflow you pull the data out and only generate outputs if there are >0 rows in both sets.
- Append the record count from each set to the other data set - and then filter this field for >0. This means that you won't write either file if either stream has zero rows
Note: You can do things in steps by wrapping them in Batch Macros - and then creating a canvas that brings all these batch macros onto 1 canvas.
For example - one batch macro to generate this data; another to do the writing. That way, you can have the benefit of having 1 workflow and still divide this into steps.
If the worry you have is that a file may fail to output because of disk space or something else - then you're going to need to do something after the write to check.
Options:
- tie a batch file to event on the end of the workflow (in workflow events) - which deletes either if the other doesn't exist
- do the same batch macro - but execute it in a Run command in a set of dependant macros like the note above.
:-) If these help to solve your problem, please mark this as solved to close this thread out @HA
Thank you
Sean
Hi Sean,
Zero row ( header only ) is a valid output however if for any reason workflow fails we don't want to generate any of the files.
I think I will use batch file to handle this and search for both files and if both are not there then delete the other one.