Getting an array from col1 and col 2 out of a csv file

hey, i'm new to node red and stuck on something simple. I have a csv file with 2 columns and 9 rows. when I read this via the read file node I get a string with these values. But my intention is to make an array from column 1 and an array from column 2. can anyone help me with this.
thank you in advance.
image

Pass it through a CSV node, set to a single message array.
That should create an array of objects, which you can then convert to any thing you wish.
e.g. An array of arrays.

[{"id":"135812e6f0ca983e","type":"inject","z":"366a43adb328cf95","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":80,"y":1040,"wires":[["652c7e6dcc75cc0c"]]},{"id":"652c7e6dcc75cc0c","type":"template","z":"366a43adb328cf95","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"1,2\n2,3\n3,4\n4,5\n5,6\n6,7\n7,8\n8,9\n9,1","output":"str","x":220,"y":1040,"wires":[["19dda518b83ea689"]]},{"id":"19dda518b83ea689","type":"csv","z":"366a43adb328cf95","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":350,"y":1040,"wires":[["afed0c6bfa9fbd91","28f8391623dab7e7"]]},{"id":"afed0c6bfa9fbd91","type":"debug","z":"366a43adb328cf95","name":"debug 93","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":980,"wires":[]},{"id":"28f8391623dab7e7","type":"change","z":"366a43adb328cf95","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t    [$$.payload.col1], \t    [$$.payload.col2]\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1080,"wires":[["b32249d8fba7a8e4"]]},{"id":"b32249d8fba7a8e4","type":"debug","z":"366a43adb328cf95","name":"debug 94","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":1080,"wires":[]}]

Example uses a change node using JSONata, but you could also use a template or function node.

1 Like

thank you so much!!!

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