Reading file line by line

Good Day

I'm reading a file and it reads everything all once using the file reader node, is it possible to read a file line by line every second. For instance:

Read-
send as payload-
wait second-
...
Read next line-
send as payloas-
wait a second....

Many Thanks

It might be helpful If you tell us more about what you are trying to do with the lines of text.

You can use the File node to read the entire contents in one go and configure it to send one message per line. Then use a Delay node configured in 'rate limit' mode to 1 message per second.

I have a large data file with around 50 000 entries, and I want to read each entry every second as a payload and convert the string into integers, then send these integers to another device, currently my setup is as described by @knolleary.

That is my current setup, I'm asking if is it possible t read each line every second because the file im reading changes aswell, from what I'm understanding, when the file updates, and the reader node reads, it reads everything all over again plus the new line.

It's going to take almost 14 hours to do what you are doing, how often does the file change? If you are using Linux you can use the "tail" node to monitor the file in real time for changes.

Exactly! lol, The solar panel system updates the data every second, so 'd like to read the new entry every second as well. Then after monitoring the file change? Re-read the whole file again?

Like I said, if you are using Linux try the Tail node. Or have I missed something?

1 Like

okay thanks let me attempt:+1:

Do you have any control over that system? It would be better for access in node-red if you could get it to do something like feeding each new value into MQTT.

Otherwise, as @ghayne suggested, use the tail node which will give you each new line as it comes in.

1 Like

Thanks @ghayne, It does what I need it to .

Thanks!