Extract Data from Many Array


Hello, i'm still fresh with node-red, i had trouble of extracting array data to csv, i did extract some of it but not all of them, this my array data

What i've done

var arrData = msg.payload.results[0].series[0].values[0];
sensorData1 = [String(arrData[0]),String(arrData[1])]
msg.payload = String(sensorData1)
return msg;

This is the result


The result is what i expected but the trouble is, the array data is too much, it can reach thousand in some condition, it will be impossible to using my code above, is anybody can suggest how to do this ? Thank you.


Hi, there are many possible ways to do such data transformation. When it comes to large and complex datasets my personal preference is to use a jsonata expression. We could help you better if you manage to export your dataset to a text file and share this file with us. You can use a pair of nodes like below to save the msg.payload to a file in your system. Just make sure to edit the file node to use a valid folder from your computer.

[{"id":"3f42a918.278f56","type":"json","z":"862de1fd.259ca","name":"","property":"payload","action":"str","pretty":false,"x":470,"y":160,"wires":[["c7654a2.10ddbb8"]]},{"id":"c7654a2.10ddbb8","type":"file","z":"862de1fd.259ca","name":"Save JSON","filename":"C:\\Users\\OCM\\.node-red\\static\\nrfiles\\dataset.json","appendNewline":true,"createDir":false,"overwriteFile":"true","x":630,"y":160,"wires":[["6720364b.7442c8"]]}]