# How to create csv/excel from object names and values

**URL:** https://discourse.nodered.org/t/how-to-create-csv-excel-from-object-names-and-values/80490
**Category:** General
**Created:** [11 August 2023 09:26 UTC](https://discourse.nodered.org/t/how-to-create-csv-excel-from-object-names-and-values/80490 "2023-08-11T09:26:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stain3565](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stain3565/32/68179_2.png) [@stain3565](https://discourse.nodered.org/u/stain3565)
#### Post date: [11 August 2023 09:26 UTC](https://discourse.nodered.org/t/how-to-create-csv-excel-from-object-names-and-values/80490/1 "2023-08-11T09:26:26Z")

</div>

I know this will be simple but I don't know how to do it.

I have a payload that is a list of objects and values. There are a variable number of such objects so it could be 1 to many.

an example of the data is below:

```auto
{"node-red-contrib-cifs":"~0.0.3","node-red-contrib-filter":"~0.1.4","node-red-contrib-float":"~1.0.3","node-red-contrib-fs-ops":"~1.6.0","node-red-contrib-ftp":"~0.0.6","node-red-contrib-mios":"~0.2.0","node-red-contrib-rsync":"~1.1.1","node-red-contrib-smb":"~1.2.0"}

```

All I want to do is create a csv/excel file of this list with the headers of "Package" for the object names and "Version" for the value.

![2023-08-11](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a0701719c38442750a6354830d34a04d868915eb.png)

Thought I could use the csv node but that seems to create the object name as a column, not a csv value.

What nodes should I be using?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 August 2023 10:23 UTC](https://discourse.nodered.org/t/how-to-create-csv-excel-from-object-names-and-values/80490/2 "2023-08-11T10:23:54Z")

</div>

The CSV node - but it expects your data to be in a useable format.

Here I use a function node to convert your data into an array of objects before passing it to the CSV node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44a1e550d5279560a09759347c8e3143fb94d609.png)

Demo flow: (use `CTRL-I` to import)

```auto
[{"id":"0a15c51a2cde6325","type":"inject","z":"1ca1817447127d22","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1370,"y":280,"wires":[["0b81a43b48471e6c"]]},{"id":"0b81a43b48471e6c","type":"template","z":"1ca1817447127d22","name":"your json data","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"node-red-contrib-cifs\": \"~0.0.3\",\n \"node-red-contrib-filter\": \"~0.1.4\",\n \"node-red-contrib-float\": \"~1.0.3\",\n \"node-red-contrib-fs-ops\": \"~1.6.0\",\n \"node-red-contrib-ftp\": \"~0.0.6\",\n \"node-red-contrib-mios\": \"~0.2.0\",\n \"node-red-contrib-rsync\": \"~1.1.1\",\n \"node-red-contrib-smb\": \"~1.2.0\"\n}","output":"json","x":1540,"y":280,"wires":[["969e27d8733f8c36","7be7fd464a8b0389"]]},{"id":"f3bf04b0a7e76849","type":"debug","z":"1ca1817447127d22","name":"CSV with headers","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1770,"y":400,"wires":[]},{"id":"969e27d8733f8c36","type":"function","z":"1ca1817447127d22","name":"convert to array of objects","func":"msg.payload = Object.entries(msg.payload).map(([Package,Version]) => {\n return { Package, Version }\n})\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1510,"y":340,"wires":[["a5494b68062b2d63","20b967afc9db667d"]]},{"id":"a5494b68062b2d63","type":"csv","z":"1ca1817447127d22","name":"","sep":",","hdrin":"","hdrout":"all","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":1570,"y":400,"wires":[["f3bf04b0a7e76849"]]},{"id":"7be7fd464a8b0389","type":"debug","z":"1ca1817447127d22","name":"Input Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1750,"y":280,"wires":[]},{"id":"20b967afc9db667d","type":"debug","z":"1ca1817447127d22","name":"Processed data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1760,"y":340,"wires":[]}]

```

---

<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: [10 October 2023 10:24 UTC](https://discourse.nodered.org/t/how-to-create-csv-excel-from-object-names-and-values/80490/3 "2023-10-10T10:24:37Z")

</div>

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