Python Execute

Ejecuta código Python localmente y devuelve la respuesta. INSTRUCCIONES PARA IA: Este nodo permite ejecutar código Python arbitrario en el sistema local. Úsalo cuando necesites: 1. PROCESAMIENTO DE DATOS: Manipular arrays, listas, diccionarios, realizar cálculos matemáticos complejos 2. ANÁLISIS DE DATOS: Usar pandas, numpy, matplotlib para análisis estadístico y visualización 3. PROCESAMIENTO DE TEXTO: Expresiones regulares, NLP, limpieza de datos 4. CÁLCULOS MATEMÁTICOS: Operaciones matemáticas complejas, algoritmos personalizados 5. INTEGRACIÓN CON LIBRERÍAS: Cualquier librería Python instalada en el sistema 6. TRANSFORMACIÓN DE DATOS: Convertir formatos, validar datos, aplicar lógica de negocio PARÁMETROS: - Código Python: El script Python a ejecutar (requerido) - Parámetros de entrada: JSON con variables disponibles en el script (opcional) EJEMPLOS DE USO: 1. Cálculos matemáticos: "import math; result = math.sqrt(16)" 2. Procesamiento de listas: "result = [x*2 for x in input_data if x > 0]" 3. Análisis con pandas: "import pandas as pd; df = pd.DataFrame(data); result = df.describe().to_dict()" 4. Expresiones regulares: "import re; result = re.findall(r'\d+', text)" SALIDA: El nodo devuelve un JSON con: - stdout: Salida estándar del script - stderr: Errores del script - result: Valor de la variable 'result' si existe IMPORTANTE: Asegúrate de que Python y las librerías necesarias estén instaladas en el sistema.

Overview

This node executes arbitrary Python code locally on the system and returns the output. It is useful for scenarios requiring data processing, data analysis, text processing, complex mathematical calculations, integration with Python libraries, and data transformation. For example, it can be used to perform mathematical operations, manipulate lists, analyze data with pandas, or run regular expressions.

Use Case Examples

  1. Calculations: 'import math; result = math.sqrt(16)'
  2. List processing: 'result = [x*2 for x in input_data if x > 0]'
  3. Data analysis with pandas: 'import pandas as pd; df = pd.DataFrame(data); result = df.describe().to_dict()'
  4. Regular expressions: 'import re; result = re.findall(r'\d+', text)'

Properties

Name Meaning
Código Python The Python code to execute. You can import libraries. This is a required field.
Parámetros de entrada (JSON) Input variables available as variables in the Python script. Must be a valid JSON object. Optional; leave empty to pass no parameters.

Output

JSON

  • stdout - Standard output from the Python script execution.
  • stderr - Standard error output from the Python script execution, including any error messages.
  • result - The value of the 'result' variable from the Python script if it exists; otherwise null.

Dependencies

  • Requires Python installed on the local system to execute the script.

Troubleshooting

  • Ensure the input parameters are a valid JSON object; otherwise, the node will throw a JSON parsing error.
  • Make sure Python is installed and accessible in the system PATH; otherwise, execution will fail.
  • Errors in the Python code will be captured in the 'stderr' output field.
  • Temporary Python script files are created and deleted during execution; ensure the system allows file creation in the temp directory.

Discussion