# How to set the reading speed of the CSV or File Read node?

**URL:** <https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897>\
**Category:** General\
**Tags:** function-node\
**Created:** [24 April 2023 20:12 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897 "2023-04-24T20:12:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [24 April 2023 20:12 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/1 "2023-04-24T20:12:47Z")

</div>

I am trying to simulate an experiment. The setup I have is like below:

 ![Screenshot 2023-04-24 at 21.02.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0bc1437687d81194cfeb6229ecf2646d727c84a8.png)  
The issue is that **file read node** works too fast for me. I need to set up this in a way that data are forwarded to a database at 20Hz.

That **function 2** is just forwarding messages right now. I am brainstorming over if I can do this via function node.

I appreciate any advice.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [24 April 2023 20:43 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/2 "2023-04-24T20:43:05Z")

</div>

Can you overwrite the file at 20Hz?  
A Watch-file node to detect the change wired to a file-in node to read the entire file (one line each time)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 April 2023 20:58 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/3 "2023-04-24T20:58:07Z")

</div>

Or do you mean that the individual lines come too quickly? In which case insert a Delay node set to Rate Limit mode, with the rate set at 20 per second.  
It would, however, be much more efficient to write them all at once by passing the influx node a complete array of records.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [25 April 2023 07:51 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/4 "2023-04-25T07:51:41Z")

</div>

Yes, that is what I mean. If I insert a delay node, it just outputs all at once with given intervals.

What I mean is that, I inserted one and set it to 50ms, then each 50ms, it outputs not 1 but X number of lines that csv node forwarded.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [25 April 2023 07:59 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/5 "2023-04-25T07:59:34Z")

</div>

> Or do you mean that the individual lines come too quickly? In which case insert a Delay node set to Rate Limit mode, with the rate set at 20 per second.

Oh, I see now, I haven't realized there was such an option.

> It would, however, be much more efficient to write them all at once by passing the influx node a complete array of records.

Could you elaborate this please?

**Edit:** When I use Rate Limit, Node-RED dies for some reason.

```auto
node-red.service: Main process exited, code=killed, status=9/KILL
node-red.service: Failed with result 'signal'.

```

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [25 April 2023 08:33 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/6 "2023-04-25T08:33:59Z")

</div>

Hi @hkayan, I am not sure why your node-red died, but maybe your file is too large?  
If you find that he delay node is not precise enough I suggest my custom node [@cameo69/node-red-ratelimit](https://flows.nodered.org/node/@cameo69/node-red-ratelimit). In my testing it works fairly precise even for short intervals and in my testing it handled even large queues of 1mio msg without issues.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [25 April 2023 15:25 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/7 "2023-04-25T15:25:33Z")

</div>

Many thanks, I will give it a try.

In the meantime, my workaround is just using a Python script with **exec node.**

 ![Screenshot 2023-04-25 at 16.24.29](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/524da2a29b66a6082a71a9103c1fef9cef982d4c.png)

---

<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:** [24 June 2023 15:26 UTC](https://discourse.nodered.org/t/how-to-set-the-reading-speed-of-the-csv-or-file-read-node/77897/8 "2023-06-24T15:26:31Z")

</div>

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