Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Output files either both or none

HA
8 - Asteroid

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,

5 REPLIES 5
ThizViz
11 - Bolide
Off the top of my head, you might be able to count the records before your output and add a test condition that will stop the workflow if either count is 0.
@thizviz aka cbridges, Bolide
http://community.alteryx.com/t5/user/viewprofilepage/user-id/2328
HA
8 - Asteroid

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,   

ThizViz
11 - Bolide
Another possibility is to use yxdb as your initial output. Then you can create a workflow that pulls in each yxdb and counts the rows before creating the csv files. It requires 2 workflows, which you can run consecutively using the runner macro, but it might do the trick.
@thizviz aka cbridges, Bolide
http://community.alteryx.com/t5/user/viewprofilepage/user-id/2328
SeanAdams
17 - Castor
17 - Castor

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

 

HA
8 - Asteroid

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.

 

 

Labels