Parsing Space Separated Text Line

I need some guidance to display data from my weather station to the dashboard.

My weather station software sends a single line, space separated text file containing 56 fields about every 15 seconds. This file is sent to a local network server. I only need to refresh every few minutes.

I'm not sure how to get the text file into NR and then parse and pull out just the data I'm interested in?

I plan to only display 3 or 4 of the 56 parameters on the dashboard.

Any direction/suggestions would be appreciated.

If the fields are always the same then I'd look at the CSV node and change it to use a spacd

I have played with the CSV node and it appears to work. However I'm not even sure how to pull the text file from my server and inject it into the flow?

You can use a File In node.

I tried the File In node and using the absolute path get an error.

Error: ENOENT: no such file or directory, open ''

From a browser, does return the realtime.txt file. But even this path still returns the error message from the File In node.

Which server is the file on, and which server is node-red running on (not the browser, that is immaterial)?

NR is on and is able to ping the server at .97

Ok, when you said is available on the server I thought you meant the node red server. The file node only works for local files (or those available via a mount). If you mounted the relevant server folder on the node red machine then you could use the File node, however, if it is available via http (as you appear to be suggesting as it is accessible from the browser) then you should be able to use an http request node to fetch it.

The http request node worked. Now I need to figure out how to pull out the selected space separated data fields. Some of the fields like temp could go from 3 digit to 4 this summer so just counting spaces from the beginning of the file won't work.

Not sure if I assign a variable to the needed fields? As you can tell, I'm learning from the ground up.

I've discovered the CSV node in space separator mode works by putting each field in it's own column like dceejay suggested. I'm not familiar with working with columns as an Object so I guess that's my next thing to investigate.

Colin, I'm hitting a dead end trying to understand how to deal with msg.payload object indexed into col1, col2, col3, etc.

How do I make use of these objects?

Depends what you want to do with the values.

Show us what your Payload looks like (expand all the properties) and explain what you are trying to do with it

Ps, There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.


Also, I think the csv node lets you allocate meaningful names to the columns doesn't it? That will make it much easier to remember what is what.

[{"id":"9dcb260f.fbfcd8","type":"inject","z":"3a16f046.5aaa9","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23/05/21 09:30:29 70.8 75 62.5 1.0 2.0 164 0.00 0.00 30.192 SSE 1 mph F in in 26.9 -0.004 5.06 11.59 0.23 75.9 59 70.8 +1.1 70.8 09:24 65.5 02:06 8.0 04:50 12.0 04:46 30.219 00:21 30.185 05:17 3.0.0 3036 5.0 70.8 80.1 0.0 0.000 0 152 0.00 18 1 0 SSE 1890 ft 74.5 0.0 620 0","payloadType":"str","x":240,"y":140,"wires":[["e56434d2.a2bf08"]]},{"id":"e56434d2.a2bf08","type":"csv","z":"3a16f046.5aaa9","name":"","sep":" ","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":460,"y":140,"wires":[["c7330d42.422d5"]]},{"id":"c7330d42.422d5","type":"debug","z":"3a16f046.5aaa9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":780,"y":140,"wires":[]}]

I would like to display a few of these selected values to the dashboard. I'm not seeing in the CSV node a way to give meaningful names to the columns. I've used msg.payload before to send text to the dashboard but the Object has got me confused.

Use the copy path button like I explained in the last post & paste it into the dashboard UI field where you previously used msg.payload

In the csv node you can give columns name and ignore others buy a comma seprate list

so col1 and col2 will be named, then col3 and col4 will be missed, then col5 will be named. Any not in list will be ignored. This way you can name your columns and ignore certain columns

[{"id":"e56434d2.a2bf08","type":"csv","z":"c74669a0.6a34f8","name":"","sep":" ","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"name1,name2,,,name3","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":370,"y":2900,"wires":[["c7330d42.422d5"]]}]
1 Like

I got the CSV node naming figured out thanks to E1cid. His example got through the fog.

I can now hover over the msg.payload Object that I have labeled as temp and use the copy path button. But pasting that into a Dashboard Text node value format only produces payload.temp. Which is naturally what shows up on the Dashboard.

It appears I need some clarification of the correct syntax for Value Format in the Text node.

Read the built in help. I'm pretty sure it tells you to use mustache syntax e.g. {{payload.temp}}

Many thanks to all that replied and offered helpful hints and solutions. I finally found time to make things work as I had wanted.

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