How get only one value from a CSV file

Hello, I have a query. I am currently graphing a data series from a .CSV file and everything is perfect, but now I need to grab the last recorded value of a single column in particular. The file contains 4 columns, A,B,C,D but I only require the last recorded value of column C for example, and then display it on the dash board with the "text" node. In this file the data is stored from the oldest to the most current. I hope you help me, regards.

Hi, maybe this flow helps you to implement the solution. Please compare the csv node configuration, maybe you have to implement a second csv node as a parallell process if configuration differs.

[{"id":"62d4cd6ea399baad","type":"tab","label":"NodeRED Forum","disabled":false,"info":"","env":[]},{"id":"f5d8a8ad2ece901b","type":"inject","z":"62d4cd6ea399baad","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":320,"wires":[["0d45f18f95325db3"]]},{"id":"0d45f18f95325db3","type":"template","z":"62d4cd6ea399baad","name":"CSV Mock","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":"A,B,C,D\n1,0,0,0\n0,0,0,0\n\"\",'',0,text\n1,2,Last Entry,4","output":"str","x":510,"y":320,"wires":[["6f8992d43ba9f6b8"]]},{"id":"6f8992d43ba9f6b8","type":"csv","z":"62d4cd6ea399baad","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":false,"include_empty_strings":true,"include_null_values":true,"x":650,"y":320,"wires":[["439c81a9c1ec0ec1","23179cba66629e22"]]},{"id":"ea5df47ef2ac3295","type":"debug","z":"62d4cd6ea399baad","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1020,"y":320,"wires":[]},{"id":"439c81a9c1ec0ec1","type":"function","z":"62d4cd6ea399baad","name":"Get Last Array Element","func":"var rows    = msg.payload;\nvar lastRow = rows.pop();\nmsg.payload = lastRow.C;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":320,"wires":[["ea5df47ef2ac3295"]]},{"id":"ad9629160c1416a5","type":"comment","z":"62d4cd6ea399baad","name":"Should ","info":"","x":350,"y":280,"wires":[]},{"id":"23179cba66629e22","type":"debug","z":"62d4cd6ea399baad","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":260,"wires":[]}]

Cheers

There is also this thread that would give you some valuable pointers in how to achieve it

Craig

Hello, I implemented this flow with the corresponding modifications, but when running it the node red was blocked and I could not reconnect. I had to delete the root flow to be able to access it again, I don't know what could have happened. :frowning:

If you make a mistake in the flow which causes node-red flows to lock up for some reason, you can start node-red using
node-red --safe
which will start the editor without starting the flows. Then you can fix the problem and deploy to start the flows running.

Thank you for your reply. I am trying to resolve the main issue. :frowning:

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