Edit CSV files in a flow?

Is it possible to edit CSV files in a node red flow? Or browser somehow?

I am interacting with another building automation type platform with Node Red and for each device on this separate platform there is a CSV file containing the device "points" for like temperature sensors, valve/damper actuators on an HVAC system.

Is there a way to edit CSV files in Node Red without having to use Nano from Linux terminal as shown in the screenshot below.?

One other option is I think this platform can also use JSON objects to represent devices/points like the screenshot above instead of CSV which Ill have to look into if JSON files can be edited in Node Red flows?

Lots of ways to interact with tabular data which is all that a CSV file is.

The simplest though is to convert to JSON, process then convert back if you need to put it back to CSV.

Other things you could do would be to load the CSV to a database and process in the db itself.

Really depends on what you need out of it.

So when setting up this other platform you discover BACnet devices in a building on a LAN by running a Python file. The script auto compiles each BACnet device as a CSV file where you can edit the points associated with each BACnet device via trimming down the CSV files to only capture the "points" you need.

Hopefully that makes sense but the VOLTTRON framework requires a CSV files for each device (framework creates this automatically by auto discovering the BACnet network)

Then once you have trimmed down the CSV files you load the files into a memory (called the VOLTTRON configuration store) by running some commands from Linux terminal.

I was curious if there is a way to do the trimming of the CSV files in Node Red without using Nano. I do think I can use JSON instead of CSV with VOLTTRON, where I may look into that... Trim down JSON files representing each BACnet device instead of a CSV file be easier and something I can do in Node Red flow???

Ultimately I can interact with VOLTTRON from Node Red via REST API to retrieve sensor values, etc.

Have a look at the CSV node, that will convert the data in a javascript object. Then you can manipulate and convert it back to CSV. You can use the File nodes to read and write the CSV data.

@Colin I can get this to work, at least I can read the csv file and see it in the debug window. maybe this is a silly idea but did you mention I could read a csv file and be able to edit the contents?

What would be cool is if I could read the CSV file and edit it like a text editor or Excel, and then write it back to the same directory that the file was read from. Thanks for any tips not a lot of wisdom here.

If tools don't exist and someone is interested in creating something, how do people go about that? Could something like this be created in React or Vue.js and then publish as a node for the Node Red community?

Maybe just using a text editor directly is best and easiest. Like nodepad++

Yes you can.

By the way, at the risk of raising the ire of people on this Node-RED forum, if you are already into Python, it has most excellent tools for manipulating tabular data.

For Node-RED, your flow is 1/2 way there. It gets you the tabular data into a JavaScript object and you now need to manipulate that. You can do that various ways in Node-RED bepending on what you actually need to do to the data.

Once you've changed the data, you will simply convert the JavaScript data back into CSV form and write it back tot he same or a new CSV file.

You can do that with Node-RED as well. Having converted to a javascript object as you've already done, you can use the ui_table node which you can use to create a table editor user interface in Dashboard.

Well, then you will always have to do it by hand. And that setup will be pretty slow and clunky on most Pi's.

Thank you so much for this.... Very helpful

Im getting a little further:
https://stackoverflow.com/questions/70412835/render-csv-file-in-node-red-flow

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