Use of Variables in Python Step

How do I use Variables from the Workflow inside the Python Step?

Hello Fernando,
Execute Python Script, in Configure Tab, using Input Frames Table field we can use variables from other steps inside the Python step.
Table fields -
1] Step name - It is the name of the step from where the fields are coming from the first step.
2] Pandas Frame name - It is the variable name where all the values came from first step is stored.

I’ve attached the sample workflow for the same.
WF_InputForPythonScript.psw (16.9 KB)

1 Like

To send a variable from AutomationEdge to Python, you need to understand a golden rule: AutomationEdge doesn’t send loose variables; it sends “tables”.

All data columns that arrive at the Execute Python Script step are automatically packaged into a Pandas table (a Python library), which the system calls df by default (short for DataFrame).

Here is the straightforward step-by-step:

1. The variable must be a column

Before reaching the Python script (using a step like Get Variables, for example), your variable must be flowing as a column in the stream.

  • Example: Let’s say the incoming column is named File_Path.

2. The code to “catch” the variable

Inside the Python script tab, you will look for this column within the df package and ask it to give you the value of the first row. The code is always like this:

Python

# Creating the variable in Python using the data from AutomationEdge
my_variable = df['File_Path'].values[0]

Understanding the command:

  • df = The table containing all the data AutomationEdge delivered to Python.

  • ['File_Path'] = The exact name of the column you want to retrieve (put it inside single or double quotes).

  • .values[0] = This means “get the value of the first row” (in Python, counting starts at zero).

In a nutshell: Whenever you want to use data coming from the AutomationEdge stream inside your Python script, simply type df['COLUMN_NAME'].values[0]. Simple as that!