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

Run a python/pandas script with multiple input/output files

silvia_wang
6 - Meteoroid

Can anyone help me build a workflow to run the attached python script with multiple input/output .csv files?

In windows cmd.exe, all I need is to type "python.exe test.py". However, if I use "run command" tool in alteryx, how do I define the "Write Source" and "Read Results" fields for my script?  

Plus, what is the best way to define a pseudo in/out flow connected to the "run command" button? 

2 REPLIES 2
patrick_digan
17 - Castor
17 - Castor

@silvia_wang I'm attaching an example that worked on my end when you save it in the same directory as your test.py. When using the run command tool, you have to setup at least one of the write source and read results. In your case where you're running a static py file, you don't need either for your process to work. Alteryx still requires one. The easiest thing is to connect dummy data to input of the run command (ie write source) and write the data out to a dummy temp file (I've written out the file %TEMP%dummy.yxdb). We don't need to connect anything to the read results. We put python in the command box. We put test.py in the command arguments. it will generally run python from the workflow directory, but you may need to add the workflow directory directory explicitly (like %Engine.WorkflowDirectory%test.py) if you come across errors with it not finding test.py. It ran fine on my end.

 

In a more complex case, you could have alteryx and python interacting. You could use the write source of the run command tool to write a csv file out that your python does something with. You could then use the read results to read data back into alteryx. The idea is that the write source is a file that your script can use, and then the read results is reading in the output from your script. 

Capture.PNG

 

 

 

silvia_wang
6 - Meteoroid

Thanks for your solution @patrick_digan ! This works perfect for me!

Labels