Skip to end of metadata
Go to start of metadata



This function is one of Plugins Operation.You can find the movie in ARGOS RPA+ video tutorial.



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”.






Need help?

Technical contact to tech@argos-labs.com


May you search all operations,





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.

https://pip.pypa.io/en/stable/user_guide/#requirements-files


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





 Text from Image   



Example of files


Python script


file name = task2.py


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 = requirements.txt


# requirements.txt for pandas handling

openpyxl
pandas