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

How to run a python script before rest of alteryx workflow

user_7346
6 - Meteoroid

Hello,

 

The file types I am using are not supported by Alteryx so I have a python script that converts them to file types supported by alteryx. I have the python tool in my workflow, but I am not sure how to make sure that is the first thing run. If the python script is not run first then the input tools will not be able to find the files as they will not yet exist. I don't want the script to output anything, but that seems to be required so I just added a browse tool after the python tool. Is there a way to have this python tool run then continue with the rest of the alteryx workflow?

 

user_7346_0-1617113366149.png

 

10 REPLIES 10
jamielaird
14 - Magnetar

Hi @user_7346 ,

 

The Block Until Done tool will help you control the order of execution in your workflow. I've attached a simple example.

 

 

 

user_7346
6 - Meteoroid

Where would the python tool go in the example provided?

echuong1
Alteryx Alumni (Retired)

You should be able to achieve this with run command as well.

 

You can configure a workflow event that would run before the rest of the workflow.

 

echuong1_0-1617113959894.png

 

If you want to go the Python route, you can have the python in one workflow, and the "actual workflow" separately. You can then chain the workflows together to run sequentially either using macros, the Runner Crew macros, or chained apps. See this article for more information: https://community.alteryx.com/t5/Alteryx-Server-Knowledge-Base/Chaining-Workflows-Together/ta-p/3857... 

 

Crew macro download here: http://www.chaosreignswithin.com/p/macros.html 

 

user_7346
6 - Meteoroid

Would I be able to set the command as the Python tool? I'd like the user to be able to edit the Jupyter Notebook to be able to change the file path for the folder containing the files they would like to convert. You can do this when clicking on the Python tool, but I'm not sure how it would work with the run command.

jamielaird
14 - Magnetar

That probably wasn't the best example, since in your case you're trying to control the order of *inputs* and the example I attached is more suited to controlling the order of *outputs*.

 

Block Until Done may provide a viable solution if you can adapt your workflow to use Dynamic Inputs, as shown below:

 

jamielaird_0-1617114568309.png

 

Maskell_Rascal
13 - Pulsar

Hi @user_7346 

 

You said that the Python tool is being used to convert files, since they are in a format that is not supported by Alteryx. 

 

What is the file type prior to conversion, and what is Python converting it to?

 

We might be able to find an easier solution for you. 


Thanks!

Phil

user_7346
6 - Meteoroid

The file types before the python script are not "real" file types. When the input files are generated they take the type after the last "." For example, if a file is named "file.car" the type shows up as a ".car" file. If it was "file.house", then the file would show up as a ".house" file. My Python script just creates copies of these files as csv files. 

afv2688
16 - Nebula
16 - Nebula

Hello @user_7346 ,

 

You don't need the python tool for that. You can just open all the files as csv without an issue. The only thing you need to edit is the delimeter (in my case here I did put no delimeter (\0) and also if you want the first line to have the column names.

 

Untitled.png

 

Regards

user_7346
6 - Meteoroid

This works perfectly and will be much easier for users who do not know Python! Thank you!

Labels