I have a problem with the CSV node. In my flow, I pass an array of objects, as the payload, to the CSV node. I expect the node to output a csv string containing a line for each object in the array. The node does output a line for each object, but the data from the first object in the array is repeated in all the lines. I find this very strange.
Here is a simplified version of what I am trying to do:
[{"id":"91798dce.d68c5","type":"inject","z":"d81de417.1351d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":2660,"wires":[["a55a46c8.febe18"]]},{"id":"7f820176.a1cc","type":"debug","z":"d81de417.1351d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":2720,"wires":[]},{"id":"df9aac72.cfe4a","type":"debug","z":"d81de417.1351d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":2660,"wires":[]},{"id":"4b5a4d85.2e63e4","type":"csv","z":"d81de417.1351d8","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\r\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":510,"y":2660,"wires":[["df9aac72.cfe4a"]]},{"id":"a55a46c8.febe18","type":"function","z":"d81de417.1351d8","name":"","func":"msg.payload = []; // create an empty array\nmsg.payload[0] = {\n \"M1DriveBearingTemp\":21,\n \"M1NonDriveBearingTemp\":22,\n \"M1StatorWindingTemp\":23,\n \"M2DriveBearingTemp\":24,\n \"M2NonDriveBearingTemp\":25,\n \"M2StatorWindingTemp\":26\n};\n\nmsg.payload[1] = {\n \"M1DriveBearingTemp\":31,\n \"M1NonDriveBearingTemp\":32,\n \"M1StatorWindingTemp\":33,\n \"M2DriveBearingTemp\":34,\n \"M2NonDriveBearingTemp\":35,\n \"M2StatorWindingTemp\":36\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":2660,"wires":[["4b5a4d85.2e63e4","7f820176.a1cc"]]}]
The picture below shows the debug output before and after the CSV node. As you can see, even though the two objects have different values, the CSV lines are identical and match only the first object.
Any insight would be much appreciated.