Skip a line at each comma (use of node function ?)

Hello everybody,

Need you, to take up a new challenge (for me)

I would like to skip a line at every comma

have the second email in the second line of the same column

have the second name in the second line of the same column


Could you help me ?

@Aurelien_Garrigaud Check the example below

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        360
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      Email: '[email protected],[email protected]',\n      Nom: 'Doe,Smith',\n      Prénom: 'jhon,jhon',  \n      'Statut du lead': 'Nouveau'\n    }\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        490,
        360
      ],
      "notesInFlow": true,
      "notes": "Mockup data"
    },
    {
      "parameters": {
        "functionCode": "const results = [];\n\nfor (const item of items) {\n  const data = item.json;\n  const emails = data.Email.split(',');\n  for (const [index, email] of emails.entries()) {\n    results.push({\n      json: {\n        email,\n        nom: data.Nom.split(',')[index],\n        prénom: data.Prénom.split(',')[index],\n        \"statut du lead\": data['Statut du lead'],\n      }\n    })\n  }\n}\n\nreturn results"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        750,
        360
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@RicardoE105 you are a killer. IT WORKS PERFECTLY :slight_smile:

1 Like

Glad it worked. Let us know if you have other questions.