IF node to count items in Extract from CSV JSON Output

Question #1: How do I use the IF node to count the number of items from the Extract from CSV node before it?

Question #2: How do I extract the first 9 items if total number of items is less than or equal to 10.

Here’s the output of Extract from CSV Node:

Note: There are 11 items

[
  {
    "Brand": "Pet Brand Name",
    "Product": "Calming Soft Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Cranberry Urinary & Kidney Chews for Cats"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Salmon Oil Soft Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Cat Hairball Control Chews for Cats"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Calming Soft Chews for Cats"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Cranberry Urinary & Kidney Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Allergy Aid and Antioxidant Chews for Dogs & Cats"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "No Stool Eating Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "All-In-One Vitamin Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Joint Health Chews for Dogs"
  },
  {
    "Brand": "Pet Brand Name",
    "Product": "Probiotic Chews for Dogs"
  }
]

n8n setup

  • Running n8n via cloud:

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

@jayalfiep , there could be a few ways to do it. Here’s just one of them. If that does not suit you, explain why, and I could offer other ways. This solution is based on the usage of Summary node in the aggregation mode “Count”.

1 Like

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