# CSV and limiting output

**URL:** <https://discourse.nodered.org/t/csv-and-limiting-output/76837>\
**Category:** General\
**Created:** [22 March 2023 20:05 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837 "2023-03-22T20:05:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tinbum1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tinbum1/32/60100_2.png) [@Tinbum1](https://discourse.nodered.org/u/Tinbum1)\
**Post date:** [22 March 2023 20:05 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837/1 "2023-03-22T20:05:22Z")

</div>

I have a flow that accesses date on the web that is in CSV format. The CSV is updated with new information added to the first few rows. That is all I am interested in.

I'm not sure why my flow won't work and only allow the first 100 messages through.

```auto
[{"id":"8be23377afc3327e","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"6e75254b2a6dbc45","type":"inject","z":"8be23377afc3327e","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":200,"wires":[["f5d13f178f205ce6"]]},{"id":"f5d13f178f205ce6","type":"http request","z":"8be23377afc3327e","name":"Test","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://data.nationalgrideso.com/backend/dataset/22bc9bdd-4919-439a-95b8-5213bb3bdf4c/resource/a2dd7992-32d5-4723-b0f5-273caaecbde1/download/service-update-industry-notifications-test150220231030.csv","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":430,"y":200,"wires":[["117a41275d1be480"]]},{"id":"117a41275d1be480","type":"csv","z":"8be23377afc3327e","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":550,"y":200,"wires":[["df8f0c10c749bf37"]]},{"id":"af176573fce1c9ad","type":"delay","z":"8be23377afc3327e","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":900,"y":180,"wires":[["1f3c09a91373ab2d"]]},{"id":"df8f0c10c749bf37","type":"delay","z":"8be23377afc3327e","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"100","nbRateUnits":"10","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":2,"x":710,"y":200,"wires":[["af176573fce1c9ad"],["d16dc28241588aaf"]]},{"id":"1f3c09a91373ab2d","type":"debug","z":"8be23377afc3327e","name":"debug 191","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":180,"wires":[]},{"id":"d16dc28241588aaf","type":"debug","z":"8be23377afc3327e","name":"debug 192","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":240,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [22 March 2023 20:26 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837/2 "2023-03-22T20:26:10Z")

</div>

limited to first 10 lines, just for example

```auto
[{"id":"117a41275d1be480","type":"csv","z":"8be23377afc3327e","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":550,"y":200,"wires":[["23b1ee0e0ad9681e"]]},{"id":"f5d13f178f205ce6","type":"http request","z":"8be23377afc3327e","name":"Test","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://data.nationalgrideso.com/backend/dataset/22bc9bdd-4919-439a-95b8-5213bb3bdf4c/resource/a2dd7992-32d5-4723-b0f5-273caaecbde1/download/service-update-industry-notifications-test150220231030.csv","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":430,"y":200,"wires":[["117a41275d1be480"]]},{"id":"23b1ee0e0ad9681e","type":"switch","z":"8be23377afc3327e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"lt","v":"10","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":200,"wires":[["d16dc28241588aaf"]]},{"id":"6e75254b2a6dbc45","type":"inject","z":"8be23377afc3327e","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":200,"wires":[["f5d13f178f205ce6"]]},{"id":"d16dc28241588aaf","type":"debug","z":"8be23377afc3327e","name":"debug 192","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":240,"wires":[]}]

```

but if the online service has ssh you should be able to do some thing like [`scp user@host:/some/file /dev/stdout | head > destfile`](https://stackoverflow.com/questions/39363510/read-first-n-lines-of-a-huge-file-from-remote-server-using-bash-command) using the exec node Depending on your set up.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [22 March 2023 20:40 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837/3 "2023-03-22T20:40:03Z")

</div>

or you could set your CSV node's Output to create a "single msg array" instead of individual msgs and slice the amount of elements you need from it.

In the example we slice the top 5

```auto
[{"id":"6e75254b2a6dbc45","type":"inject","z":"8be23377afc3327e","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":240,"wires":[["f5d13f178f205ce6"]]},{"id":"f5d13f178f205ce6","type":"http request","z":"8be23377afc3327e","name":"Test","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://data.nationalgrideso.com/backend/dataset/22bc9bdd-4919-439a-95b8-5213bb3bdf4c/resource/a2dd7992-32d5-4723-b0f5-273caaecbde1/download/service-update-industry-notifications-test150220231030.csv","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":310,"y":240,"wires":[["117a41275d1be480"]]},{"id":"117a41275d1be480","type":"csv","z":"8be23377afc3327e","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":450,"y":240,"wires":[["42775e6038883b59","90106a345a021b75"]]},{"id":"b8520f1a17929ef0","type":"debug","z":"8be23377afc3327e","name":"debug 193","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":240,"wires":[]},{"id":"42775e6038883b59","type":"function","z":"8be23377afc3327e","name":"slice","func":"msg.payload = msg.payload.slice(0,5) // slice first 5\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":240,"wires":[["b8520f1a17929ef0"]]},{"id":"90106a345a021b75","type":"debug","z":"8be23377afc3327e","name":"debug 192","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":180,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Tinbum1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tinbum1/32/60100_2.png) [@Tinbum1](https://discourse.nodered.org/u/Tinbum1)\
**Post date:** [22 March 2023 20:48 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837/4 "2023-03-22T20:48:41Z")

</div>

That's brilliant, thank you so much. 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 May 2023 20:49 UTC](https://discourse.nodered.org/t/csv-and-limiting-output/76837/5 "2023-05-21T20:49:38Z")

</div>

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