# HELP Convert array of objects to array of arrays using change node

**URL:** <https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266>\
**Category:** General\
**Created:** [8 November 2022 15:43 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266 "2022-11-08T15:43:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.nodered.org/u/newbie1)\
**Post date:** [8 November 2022 15:43 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/1 "2022-11-08T15:43:44Z")

</div>

Hi,  
I am new to Node-RED and I really could use some help. I am trying to read two CSV files containing tables with values and sum up the entries of the two tables. I am now stuck in the step where the CSV node gives me an array of objects which I want to convert to an array of arrays. Apparently, I can do that with a change node or with a function but I am stuck.  
 ![nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/effbde986e475e38be08f5c02ae60dbc27ef047e.png)

thanks in advance!

---

<div class="post-metadata">

**Author:** ![JustinB](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/justinb/32/68068_2.png) [@JustinB](https://discourse.nodered.org/u/JustinB)\
**Post date:** [8 November 2022 15:55 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/2 "2022-11-08T15:55:33Z")

</div>

Hey, could you visualize how you want it to look like?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 November 2022 15:56 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/3 "2022-11-08T15:56:08Z")

</div>

looks like you need to set your csv node separator to `;` semicolon.  
Then in a change node you could use JSONata to a sum the column, something like  
`$sum($$.payload.col1)`

---

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.nodered.org/u/newbie1)\
**Post date:** [8 November 2022 16:01 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/4 "2022-11-08T16:01:08Z")

</div>

thanks for the quick reply, it is supposed to be an array of arrays, sthg like [[1,4], [2,5], [3,6]]

---

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.nodered.org/u/newbie1)\
**Post date:** [8 November 2022 16:04 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/5 "2022-11-08T16:04:11Z")

</div>

> [@E1cid](#):
>
> ooks like you need to set your csv node seperator to `;` semicolon.

humm, how can I do that?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 November 2022 16:08 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/6 "2022-11-08T16:08:28Z")

</div>

Maybe look in the csv node settings, where it says separator.

e.g.

```auto
[{"id":"eeb9211a8f426608","type":"template","z":"452103ea51141731","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"1;4\n2;5\n3;6","output":"str","x":240,"y":3660,"wires":[["1ea8d77edebaa5e4"]]},{"id":"e6a0e1f18fc8f86f","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":3660,"wires":[["eeb9211a8f426608"]]},{"id":"1ea8d77edebaa5e4","type":"csv","z":"452103ea51141731","name":"","sep":";","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":310,"y":3700,"wires":[["5626199d0b983e3e","0e936280b366a6f0"]]},{"id":"5626199d0b983e3e","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.[$.*]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3700,"wires":[["71b6e778f177aa3d"]]},{"id":"0e936280b366a6f0","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sum($$.payload.col1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3740,"wires":[["15e9acb625811019"]]},{"id":"71b6e778f177aa3d","type":"debug","z":"452103ea51141731","name":"debug 107","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":3700,"wires":[]},{"id":"15e9acb625811019","type":"debug","z":"452103ea51141731","name":"debug 108","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":3740,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.nodered.org/u/newbie1)\
**Post date:** [8 November 2022 16:13 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/8 "2022-11-08T16:13:14Z")

</div>

I managed to change it and it helped, thanks!  
PS: I keep seeing the thing you attached as an example everywhere, I know they are supposed to help but I have no idea what they are 😅

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 November 2022 16:15 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/9 "2022-11-08T16:15:01Z")

</div>

They are example flows. If you had read the doc's you would know what they are and how to use them [Importing and Exporting Flows : Node-RED](https://nodered.org/docs/user-guide/editor/workspace/import-export) . I suggest you spend some time reading and watching the videos, it will save you a lot of time and enable you to make better use of node-red and the in built tools.

---

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.nodered.org/u/newbie1)\
**Post date:** [8 November 2022 16:20 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/10 "2022-11-08T16:20:37Z")

</div>

thanks a lot! I'll definitely look into that

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 January 2023 16:20 UTC](https://discourse.nodered.org/t/help-convert-array-of-objects-to-array-of-arrays-using-change-node/70266/11 "2023-01-07T16:20:39Z")

</div>

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