Alteryx Designer Desktop Discussions

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

Append or create new file

aleks_filipov
5 - Atom

I am new to Alteryx and I have created a macro that downloads the data from API and saves it into csv file. However I want to run the workflow each day and append the data in the same file for the whole month and from the next month new file should be generated.My problem is, the Dynamic Input is failing when the file is missing and I want to skip the Dynamic Input and create new file from the extracted data.Capture.PNG

6 REPLIES 6
DavidP
17 - Castor
17 - Castor

Hi @aleks_filipov 

 

The way I would do this is to load the latest data file and include the filename as a field in the output. You can then filter all rows where the month is not the current month and union the result with your downloaded data. If there are no valid rows, no data will be added. Something like this:

 

DavidP_0-1635174523166.png

 

DavidP
17 - Castor
17 - Castor

Also, looking at your workflow. you can remove the block until done tool - it serves no purpose

aleks_filipov
5 - Atom

Hi,

 

This is very good idea but it will not work in my case. In the same folder there are multiple files with different sources and this will take the last created which is not the one that we need. Also, what if there are no files at all and they yet to be created.

 

Regards,

Alex

Pang_Hee_Choy
12 - Quasar

you can try to create the file if it not exist (like below). and put the block until done tool before the dynamic input.

Or you manual create all the month file in advance.

Pang_Hee_Choy_0-1635237472653.png

 

DavidP
17 - Castor
17 - Castor

Hi @aleks_filipov

 

With the directory tool you can be much more specific than just *.* (everything in the folder).

 

You can tell it to only load excel files (*.xlsx), or you can limit the results by filename and type, like api_data*.csv

 

So you can see how you can manipulate the Directory tool to only return the correct file.

 

It is true that you'll have problem if the file doesn't exist, but this will only be true the 1st time. My suggestion is that you create a file with now data in it.

 

There are other things you can do like put a certain part of the workflow in a container that you can dynamically disable or enable, or look at something like a detour tool, but this all gets very complicated and that is not necessary.

aleks_filipov
5 - Atom

I have added additional macro within the macro for loading existing files and the issue with the errors has been solved.

aleks_filipov_0-1635339914120.png

 

Labels