Node to read a text file line by line ?

3,903 views
Skip to first unread message

Rahul Prajapati

unread,
Apr 24, 2015, 9:34:54 AM4/24/15
to node...@googlegroups.com
Hi 
I want to read a text file line by line and display on msg.paylod one by one after a time gap.

Ex-
Hi
wait for 10 sec.
Node-red
wait for 10 sec
ibm


Message has been deleted

Nicholas O'Leary

unread,
Apr 24, 2015, 10:04:19 AM4/24/15
to node...@googlegroups.com

Hi Rahul,

We have all the nodes for that in palette - one to read files, function node to split the content etc

What have you tried so far?

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rahul Prajapati

unread,
Apr 24, 2015, 10:15:39 AM4/24/15
to node...@googlegroups.com
Hi Nick 
I just want to  read a text file and  split the data by /n and display on msg.payload.
 which node i should be use when i want to split the data of a file.

rahul

Mark Setrem

unread,
Apr 24, 2015, 10:24:13 AM4/24/15
to node...@googlegroups.com
You will need to write a function node to do the splitting. Take a look at the documention which includes a couple of examples that might be useful

Dave C-J

unread,
Apr 24, 2015, 10:28:02 AM4/24/15
to node...@googlegroups.com
When you read a file it gets loaded as one long string... so you will need a function that splits strings into an array... and then returns multiple messages.

Rahul Prajapati

unread,
Apr 27, 2015, 6:33:14 AM4/27/15
to node...@googlegroups.com
Thanks  Dave 

I done with print multiple message on payload.but i want to print it one by one in a time duration.

for example:
msg1
// then wait for 10 sec
msg2
// then wait for 10 sec
msg3

Nicholas O'Leary

unread,
Apr 27, 2015, 6:35:34 AM4/27/15
to Node-RED Mailing LIst
You can use the Delay node to introduce a delay between messages.

--

Rahul Prajapati

unread,
Apr 27, 2015, 6:48:49 AM4/27/15
to node...@googlegroups.com
Thanks Nick
I tried delay node but it didnt work in my case.
My task is:
I am reading a text file using file node.then i am using function node to split function to split the file data line by line.
in my text file there are multiple lines.I want to print it on payload one by one using delay.but when i am injecting my flow it return all line in same time,

what should I do nick.

Rahul


Mark Setrem

unread,
Apr 27, 2015, 6:56:11 AM4/27/15
to node...@googlegroups.com
If you've created the function node correctly, it should be outputting a different message for each line.

As Nick has said you can then configure the delay node to output a message every X number of seconds.
You need to configure the delay node to "Limit rate to" .

If that doesn't work you'll need to provide some further details of what you have done such as a screen image of your flow, & the code of your function node.

Rahul Prajapati

unread,
Apr 27, 2015, 7:19:50 AM4/27/15
to node...@googlegroups.com
Thanks Mark & Nick

Now its working.

Thanks a lot

Rahul

Reply all
Reply to author
Forward
0 new messages