Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Python tool - passing and running a completed script.

AndrewS
11 - Bolide

Hi all,

 

Just starting to play with the Python tool in 2019.1. I'm trying to create a simple workflow to move files around. I can't work out how to run the data coming into the tool (#1). All my attempts have just read in the file and not actually run the script.

 

The flow takes text files with the imports and body of the script, I union this together and then Summarise / concatenate with a \n. The text files will eventually become macro inputs

 

When I take this output and manually paste it runs, so I think the script is OK. I'm struggling to get the tool to run the script when it passes into the Python tool.

 

I've tried Alterx.read("1") and it reads Ok, but no files get moved, I'm guessing .read is not the way to do it.

 

Any suggestions appreciated.

 

Thanks.

 

Spoiler
Python.PNG
3 REPLIES 3
JoeS
Alteryx
Alteryx

Hi @AndrewS 

 

Just want to check, you have written parts of the script in the data process before the python tool using the Alteryx tools?

 

And you want to dynamically execute the script built in the data flow?

 

Alteryx will read the data flow into a pandas data frame. So in order to then execute that as a script you'd need to then convert from there. Unfortunately that's about where my python knowledge starts the fail me.

 

Is that something you can do?

 

Otherwise, what you can do instead is convert the process into a batch macro and pass through the data as control parameters.

 

Failing that, you can also use the run command tool create a batch file and then execute it. This would be the method I'd chose. I have attached something I did a while back to help someone else out. Let me know if you have any questions.

AndrewS
11 - Bolide

Thanks @JoeS

 

I read up on the pandas dataframe, so I took your suggestion and went with the macro approach and set up a control parameter on the productionModeScript - value. it accepted the input and ran the script & moved the files.

 

 

JoeS
Alteryx
Alteryx

Nice work. I am glad you got it doing what you wanted. (And in my head, batch files are easier than python, so that's a win)

Labels