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

Use Question.<name> in Python

kelkboom
7 - Meteor

Can somebody help me with using the Constant (parameter) option in python. here is what i did so far

 

File input propertiesFile input properties

Here i define the name of the file Input function as "SelectFile"

 

Value of the constantValue of the constant

Here i set the default value for the parameter.

 

Read constand in PythonRead constand in Python

Here i try to read the parameter just like in the R module. But with no success. How do i get this working....

 

regards Humberto

 

3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor

@kelkboom  It currently cannot be done. 

 

1) Make sure you don't run the entire workflow and pass a value that contains a single "\" (Your SelectFile value currently has several "\"). It will error out and delete all your python code. Alteryx is aware of the issue. I haven't checked, but I suppose it should not error out if you just doubled them all up to "\\". This is only a problem for reference shortcuts, as the juypter notebook is gracefully changing "\" to "\\" whenever your code includes a "\" (but reference shortcuts are done outside of that).

 

2) You should add your idea over here.  My biggest complaint is that when you run the entire workflow, it will actually permanently replace the text. So your python code would become print("W:\......zip"). I think you should add your idea that it should also work when you run the cell as it currently does not work at all.

 

I get a lot of value from passing data this way and I think the python tool would be even better if it handled reference shortcuts similar to any other tool (and especially the R tool).

Claje
14 - Magnetar

So I don't know if this accomplishes what you are looking for or not, and my Python is still fairly minimal, so if there's a reason why this won't accomplish your need, please let me know (you'll help me learn)!


Could you have a Text Input in your workflow, with the following configuration:

Question.SelectFile
%Question.SelectFile%

 

Then you could connect this to the Python tool, and rename the connection as Question.SelectFile (for consistency)


Finally, you could try the following Python code:


from ayx import Alteryx
Alteryx.getIncomingConnectionNames()
df = Alteryx.read("Question.SelectFile")
SelectFile = df.iloc[0]['Question.SelectFile']
print(SelectFile)

I believe that the SelectFile parameter referenced above should be identical to what you are looking for.

 

claje_python_Parameter.PNG

kelkboom
7 - Meteor

Thnx for your reply. I did see these work around. and because what i want is not implemented yet i have chosen to do it this way. her is my end resulpict4.PNG

Read parameters from the input stream

 

 

pict5.PNG

 

Input stream definition

 

 

pict6.PNG

Final result of my Macro. I also inserted the macro in this post. 

Labels