Action (CODE), to pull the information that passed through (Loop Over Items or split) with python

hey guys,

I would like some help

I have the following scenario on the n8n as shown in the photo

I basically need it within an action (CODE), to pull the information that passed through (Loop Over Items or split)

this using within the CODE action, the python language, I would like to know the correct way to type within python to pull the data that passed into this field (Loop Over Items)

This would be the code in Python:

import re

def process_receitas(_input):
# Definir a expressão regular
regex = r"REC[\s\S]*?Com Desconto: \d+[.,]\d{2}"

# Obter a mensagem recebida
msg_recebida = _input.python.item.json.receita


# Encontrar todas as correspondências
lista_receitas = re.findall(regex, msg_recebida)

# Inicializar a lista de receitas fracionadas
receitas_fracionadas = []
n_rec = 0

# Criar um dicionário para cada receita encontrada
for receita in lista_receitas:
    receitas_fracionadas.append({f'receita{n_rec}': receita})
    n_rec += 1

# Atualizar a quantidade de receitas
_input.item.json.quantidade_receitas = len(lista_receitas)

# Retornar as receitas fracionadas
return receitas_fracionadas

output = process_receitas(_input)
return output

return _input.item

and we would like to pull this information from (Loop Over Items) in the following line of the script:

msg_recebida = _input.python.item.json.receita

if anyone can help me thank you

Information on your n8n setup

  • n8n version: 1.46.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n clould
  • Operating system: Windows

Hey @TI_Formula_Ativa,

Have you already tried using _("<node-name>").all(branchIndex?, runIndex?) or one of the options listed here: Output of other nodes | n8n Docs

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.