Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Return value if input file does not exist in directory

KuKamil
5 - Atom

Hello everybody,

 

I have an issue with running the workflow if a file does not exists in the directory. I have the following set up:

 

- Around 25 txt files are separately imported via the 'Input Data' tool 

- All of them are running through an unique workflow and are not dependent on each other

- After running the workflow the results are combined and outputed via the 'render tool' into one excel file with several tables and sheets

 

However, if one file out of the 25 doesn't exist in the directory, the output excel file will not be generated.

 

How can I check if the file exists in the directory and if it doesn't return some kind of value, so the output file will be generated even if the file is missing? In that case I would like to write something like: "File not in directory. Calculation not possible" in the specific cell designated for the result from the missing file.

 

I hope you can help me out ASAP as I could not find any other solution elsewhere.

 

Thanks in advance

Kamil

8 REPLIES 8
MarcSchonwandt
7 - Meteor

Hi Kamil,

 

What exactly defines when the you want the error message generated? You mention "around" 25 files, and if it is exactly 25 files, then you could use a directory tool, then count number of records and lastly have a message tool to throw you an error if the count is below 25. If this is the the case I'll gladly send over a workflow as example. 

KuKamil
5 - Atom

Hi Marc,

 

thanks for the quick response and your proposed solution. The problem is here, that the results of the single workflows, where the input files are running through, are joined by an 'Union' tool at the end and exported to a single excel file (In between there are several workflows which are changing the headers based on a config file, filled out by the user; making calculation based on input etc.).

 

The aim is that the output file will be generated in the same structure no matter how many files or which files are missing in the directory (this should happen after changing headers and before making calculations). So, if a file is missing, a string should be generated which says: "No data available". That way the output file be generated and the structure stays the same. Could be a macro more helpful?

 

The project I'm currently working on has already around 1500 tool IDs. If it is helpful I could prepare a simplified Alteryx xymd file to show you the project. However, this takes a couple hours :)

 

Thanks again!

KuKamil
5 - Atom

Hi Marc,

 

I have found another discussion which is similar to my problem. Because sometimes an input file is missing the Union tool does not work. 

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Ignoring-Missing-Data-Connection-for-U...

 

Unfortunately the proposed solution does not work, if I delete 'File3.csv.'

All in all I need to optionalize the amount of files imported and unioned.

 

Capture.PNG

Thableaus
17 - Castor
17 - Castor

Hi @KuKamil 

 

Quick tip: Try to insert a file with same column names but with no records in your Dynamic Input configuration setup. Here:

here.PNG

 

Insert this empty file in the Dynamic Input and it won't matter if you pull results from Directory Tool or not, it will bring only metadata from this empty file.

 

Cheers, 

KuKamil
5 - Atom

Hi @Thableaus 

 

my problem was that the workflow did not create the excel file (via Render tool) when one ore more files are missing.

I made a workaround by creating a macro, which is checking in the directory if all files, needed for the main workflow, are in the folder. If not, the workflow creates the missing files. After that I run my regular workflow. 

However, thanks a lot for your solutions!

Capture.PNG

Shaaz
9 - Comet

Can you please share this workflow ?

Sri9
8 - Asteroid

Can you please send the workflow you had mentioned?

Sri9
8 - Asteroid

I use 5 dynamic input tools in a workflow and if one of the file is not available then my wofkflow should be stopped. How do i do it?

Labels