Dynamic Python-3.402.913
Dynamic Python
Author: Jerry Chae
Description The Dynamic Python plugin takes a Python script and runs it. Additionally, when the Python script has any 3rd party Python modules integrated, the plugin automatically downloads and installs them in the local virtual environment for PAM. You can pass on parameters to the Python script as well. This plug in requires Python coding skills.
WARNING!
Use Dynamic Python carefully Dynamic Python alters the virtual environment file without going through PAM’s VENV Manager features. This may result in some infrequent case where a potential resource conflict may be observed when PAM tries to run another Automation Scenario with the virtual environment. When this happens, no error messages will be displayed. PAM just cannot run any Automation Scenarios anymore. If you encounter a case like above, please just delete the virtual environment file at: %userprofile%\.argos-rpa.venv The virtual environment file has a file name with date-time like “20210402-165006”.
WARNING!
Create requirements.txt carefully Dynamic Python may overwrite versions of the same library used by another plugin. Therefore, scenarios may not run properly if destructive changes have been made in different versions.
The version of the library can be checked from the scenario execution log.
NOTE Creating Python files using Curly Braces
As an example, the main types of curly braces in Python are as follows |
Input (Required)
Python script file, usually a text file with extension .py (see example below.)
Input (Optional)
Req Text
requirements.txt file is the standard text file that lists the 3rd party Python modules that the main Python script will be calling for.
Parameters
Parameters are defined in the main Python script (see example). You can pass on parameters by using the notation ::= as in Python
Encoding option
If the input file uses any other encoding options than UTF-8, you can specify it here.
Output
Return Value
This plugin does not return any values
Return Code
0 for success
9 for failure
How to set parameters
Right Text Bubble
Give full file path for the Python script to execute
Give full file path for the requirements.txt here
Pass on parameters with ::= notation
No values are returned
Left Text Bubble
Successful execution returns code 0
Failed and erroneous execution returns code 9
Example of files
Python script
file name = Dynamic Python-3.402.913
import glob
import os
import pandas as pd
from pandas import ExcelWriter
from openpyxl import load_workbook
wdir = r"{wdir}"
in_files = (
os.path.join(wdir, '1.xlsx'),
os.path.join(wdir, '2.xlsx'),
os.path.join(wdir, '3.xlsx'),
)
out_file = os.path.join(wdir, 'task2.xlsx')
writer = ExcelWriter(out_file, engine='openpyxl')
num_rows = 0
for filename in in_files:
excel_file = pd.ExcelFile(filename)
(_, f_name) = os.path.split(filename)
(f_short_name, _) = os.path.splitext(f_name)
for sheet_name in excel_file.sheet_names:
df_excel = pd.read_excel(filename)
df_excel.to_excel(writer,index=False,header=False,startrow=num_rows+1)
num_rows += df_excel.shape[0]
writer.save()
print(os.path.abspath(out_file), end='')
File name = Dynamic Python-3.402.913
# requirements.txt for pandas handling
openpyxl
pandas
Update 2022.02.08
This feature was added from v.4.205.1515
When running a Python program which requires an older or a newer version of Python interpreter, specify it at this Python Exe parameter (ARGOS Solution use Python 3.7.3)
Please note that when this parameter is checked, Text Req parameter is deactivated (ignored). This is because the dependent module usage schemes are different in older Python versions.