Python tool - passing and running a completed script.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
- Labels:
- Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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)
