How could I simplify this workflow

Describe the problem/error/question

Hi community!

N8N noob here. I’m trying to create a workflow that:

  1. Reads a relatively big csv table as binary from my Nextcloud
  2. Extracts from csv file
  3. Converts a filed from html to markdown
  4. Filters per id to create a new discrete csv table for each unique id
  5. Converts the discrete tables to CSV binary
  6. Uploads it back to the Nextcloud

In summary I split a table into multiple tables by grouping the data based on their IDs. I’ve created the below workflow but I think there is more practical ways to do it that I don’t know. As you will see in the workflow; the nodes from step 4 (Filter) to 6 (Nextcloud) are repeated/duplicated nodes. How clould I simply this workflow so that I don’t have to repeat those steps?

Thank you in advance!

Edit

Let me share the JSON schema of the table fields:

[
   {
      "id": " ",
      "obekID": " ",
      "obek": " ",
      "projeID": " ",
      "proje": " ",
      "isTipi": " ",
      "durum": " ",
      "konu": " ",
      "description": " ",
      "oncelik": " ",
      "metin": " ",
      "metinText": " ",
      "tarih": " ",
      "saat": " ",
      "zaman": " ",
      "bitisTarihi": " ",
      "bitisSaati": " ",
      "atanan": " ",
      "surum": " ",
      "iliskiliIsler": " ",
      "bagliSayfalar": " ",
      "ilgiliIslemler": " ",
      "tamamlanma": " "
   }
]

Please share your workflow

PS: I had to truncate the workflow code. Because it exceeds the character limit since it is huge. This is how it looks like, that’s why I’d like to simplify it:

Share the output returned by the last node

I have a one big issues csv table called: teknimer-proje-islemler-modified.csv and I want to transform it into multiple discrete tables per project ID. In the last output I should see the following files (names don’t matter for now, it is just illustrate what I want to achieve):

urtotm-kurucu-issues.csv
hkbrc-hw-issues.csv
hk-android-issues.csv
hkbrl-hw-issues.csv
urtotm-ceedling-issues.csv
hku-m2k0-issues.csv
urtotm-mplabx-issues.csv
saat-issues.csv
urtotm-urtotm-issues.csv
hkbrl-fw-issues.csv
hk-ios-issues.csv
hkbm-fw-v1-issues.csv
urtotm-araclar-issues.csv
hkbm-issues.csv
hkbrc-fw-issues.csv
hku-m2k05-b6-issues.csv

Information on your n8n setup

  • n8n version: 1.98.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): self-hosted with Yunohost
  • Operating system: Debian 12

Well I’ve been trying to create a simplified version of that workflow but I haven’t been able to get what I get in the previous version. Here is the workflow v2 scratch:

I would appreciate if someone points me the right direction.

your current workflow works but it’s not scalable since each projeID needs its own filter and upload nodes. Fortunately, n8n lets you eliminate that duplication.

After reading the CSV and converting it to JSON, use a Function node to group all records by projeID. You can create an object where each key is a projeID and its value is the array of rows for that ID. Then pass this to a Loop Over Items node with a batch size of 1, n8n will dynamically iterate through each group

Inside that loop, you can convert the metin field from HTML to Markdown, convert the grouped records to a CSV file, and upload directly to Nextcloud, perhaps naming the file with {{ $json.projeID }} so it’s dynamic. No need for separate filter/output nodes per projeID.

This pattern, grouping in one node and looping through groups, is common in n8n and perfectly supported . The Loop node will handle any number of IDs automatically.

Let me know if you’d like the Function code snippet or an example JSON to set this up!

1 Like

Hey @Gallo_AIA, thank you for your answer. I code in C and Java, but don’t have a Javascript background. This why I wondered if it could be done with the existing nodes. However, I would love to see a code snippet which does that grouping operation. Could you please? Thank you.