Read data from a .txt-file with 'file in'-node

Hey everyone,

sorry for the kind of 'basic' question. I didn't find it anywhere and I am doin my first steps with Node-RED.

My Problem:
I am watching a folder (wfwatch-Node). Everytime a new document (.txt) is created in that folder, i want to read that document (if its a new one). I tried it with the 'file in' node. It didn't work.

Could sombody tell me what I am doin wrong?


Thanks a lot!

Which bit didn't work ?
Did you try triggering the file read from an inject node ?
How do you have the file node configured ?
What is the switch doing ?

put some more debug nodes into your flow to see what messages are being passed.

From the screenshot it looks like you have hard coded to file name in the file node. If you read the info panel for the file node it will tell you where the file name needs to be. you will need a change node to move the file name to the correct place

Thank you for your help.

  1. Not sure what you mean. (the whole thing didn't work)
  2. No i did not. I dont think this would solve the problem.
  3. I put in the filenamepath
  4. The switch-Node is checking, if something new is 'created' in the folder.

Thanks a lot for your help.

I read it. It said 'The filename should be an absolute path'.

I tried to change it. But it still doesen't work.

I get this error now.

Ah right, on windows you may need to escape the \ with another \. So c:\\Users\\.... Etc

so as I said add debug nodes along your flow to see what messages are actually being passed.

If you want to pass the file name and path within the message being passed between the nodes it has to be in the correct position.
I’m not at my computer but I thought this was something like msg.filename but it is specified in the info panel
You must then leave the filename in the config panel blank
But as the watch node outputs the filename as msg.payload you will need to move it as well as the modification that ceejay suggested

Node red is a block structured system. To say the whole thing doesn't work doesn't really make sense, some nodes are probably working, but are not getting the right data. What I think you mean is that as a complete system you are not getting out what you expect. As others have suggested, the debugging technique to use is to start at the beginning of the flow (in this case the watch node) and put a debug node on the output of that and make sure that you are seeing what you expect. Once that is working then put a debug on the output of the next node and check that is working as expected. Follow this technique right through and flow and eventually you will get it all working, or you will come across one node that you can't fix, then you can come back and ask again.