# Add column headers to CSV file

**URL:** <https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062>\
**Category:** General\
**Created:** [3 September 2019 14:25 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062 "2019-09-03T14:25:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 14:25 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/1 "2019-09-03T14:25:19Z")

</div>

i want t create a csv file with header  
i follow this example but doesn't work. i always find the header's names in one cell ?

```auto
[{"id":"1993503b.2a2d88","type":"fs-ops-access","z":"456ce3eb.038f9c","name":"","path":"measurements","pathType":"str","filename":"test.csv","filenameType":"str","read":false,"write":true,"throwerror":false,"x":270,"y":540,"wires":[["f5a19eb1.8cf848"],["58e35a35.3ba4e4"]]},{"id":"d0c0fa9b.978bf","type":"inject","z":"456ce3eb.038f9c","name":"","topic":"test","payload":"15,20,25,30","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":500,"wires":[["1993503b.2a2d88"]]},{"id":"f5a19eb1.8cf848","type":"file","z":"456ce3eb.038f9c","name":"Save to file","filename":"measurements/test.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","x":590,"y":500,"wires":[]},{"id":"58e35a35.3ba4e4","type":"function","z":"456ce3eb.038f9c","name":"add time","func":"msg.payload = \"Title1,title2,title3\" +\"\\n\"+ msg.payload;\nmsg.error = null;\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":560,"wires":[["f5a19eb1.8cf848"]]}]

```

Any help !! And thanks in advance.

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 16:25 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/2 "2019-09-03T16:25:45Z")

</div>

i was trying to create a csv file and put each message on payload in row.  
here's a screen shot of what i get !  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d21ceefde641db2ff83e04be719414d58b6f193b.png)  
[{"id":"efbe8950.cc5658","type":"file","z":"e9466292.f6b17","name":"store2.csv","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","x":550,"y":760,"wires":[]},{"id":"8b1f8ed7.46751","type":"csv","z":"e9466292.f6b17","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\r\n","temp":"a,b,c","skip":"0","x":350,"y":760,"wires":[["efbe8950.cc5658"]]},{"id":"2c499cc2.cde794","type":"function","z":"e9466292.f6b17","name":"","func":"msg.payload = [\n { a: 80, b: 18, c: 2},\n { a: 52, b: 36, c: 10},\n { a: 91, b: 18, c: 61},\n { a: 32, b: 47, c: 65},\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":760,"wires":[["8b1f8ed7.46751"]]},{"id":"8b3290d3.6d043","type":"inject","z":"e9466292.f6b17","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":700,"wires":[["2c499cc2.cde794"]]}]

any suggestion Please !!!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 September 2019 16:30 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/3 "2019-09-03T16:30:22Z")

</div>

From the little I can see on my phone that looks fine. Looks like the import isn’t handling it

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 16:36 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/4 "2019-09-03T16:36:47Z")

</div>

> [@hathemi](#):
>
> [{"id":"efbe8950.cc5658","type":"file","z":"e9466292.f6b17","name":"store2.csv","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","x":550,"y":760,"wires":},{"id":"8b1f8ed7.46751","type":"csv","z":"e9466292.f6b17","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\r\n","temp":"a,b,c","skip":"0","x":350,"y":760,"wires":[["efbe8950.cc5658"]]},{"id":"2c499cc2.cde794","type":"function","z":"e9466292.f6b17","name":"","func":"msg.payload = [\n { a: 80, b: 18, c: 2},\n { a: 52, b: 36, c: 10},\n { a: 91, b: 18, c: 61},\n { a: 32, b: 47, c: 65},\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":760,"wires":[["8b1f8ed7.46751"]]},{"id":"8b3290d3.6d043","type":"inject","z":"e9466292.f6b17","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":700,"wires":[["2c499cc2.cde794"]]}]

thanks. iyou can import it now!!  
i don't understand where is the problem ?

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 19:02 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/5 "2019-09-03T19:02:56Z")

</div>

Any advice here ???!! it was working month ago, but now i don't what's happened ?!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 September 2019 19:46 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/6 "2019-09-03T19:46:52Z")

</div>

What problem are you trying to solve?

Your second flow doesn’t include any attempt to add column headers which is the tile of the thread.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 September 2019 19:50 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/7 "2019-09-03T19:50:12Z")

</div>

the CSV node doesn't have the output names selected - and no line ending set...  
but the output you show looks ok. (you don't append the actual file produced.)

```auto
[{"id":"b605cbe1.3e38c8","type":"csv","z":"3658255b.2041aa","name":"","sep":",","hdrin":"","hdrout":true,"multi":"one","ret":"\\n","temp":"a,b,c","skip":"0","strings":true,"x":350,"y":400,"wires":[["866f2ce2.66549"]]},{"id":"578c6f59.dbdb3","type":"function","z":"3658255b.2041aa","name":"","func":"msg.payload = [\n { a: 80, b: 18, c: 2},\n { a: 52, b: 36, c: 10},\n { a: 91, b: 18, c: 61},\n { a: 32, b: 47, c: 65},\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":400,"wires":[["b605cbe1.3e38c8"]]},{"id":"76ffaf2f.75f6d","type":"inject","z":"3658255b.2041aa","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":340,"wires":[["578c6f59.dbdb3"]]},{"id":"866f2ce2.66549","type":"debug","z":"3658255b.2041aa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":520,"y":340,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 19:58 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/8 "2019-09-03T19:58:55Z")

</div>

yeah, i was attempting to add headers but it seems that i have another problem on storing data on csv file.!!!?  
is it because the new updates on node-red nodes ?  
And How it does it work now ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 September 2019 20:01 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/9 "2019-09-03T20:01:16Z")

</div>

the example I shared works for me with latest so I don't know. can you share the file it produces ?

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 20:06 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/10 "2019-09-03T20:06:59Z")

</div>

![Sans%20titre](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1b2dba0b263966971d4d0e4919ffa16cca8c8dd1.png)  
here's my file!

---

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [3 September 2019 20:20 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/11 "2019-09-03T20:20:52Z")

</div>

Found it! it was in changing separator in csv node with semicolon ";".  
Thank you Sirs for help.

---

<div class="post-metadata">

**Author:** ![Samira05](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Samira05](https://discourse.nodered.org/u/Samira05)\
**Post date:** [13 April 2021 07:50 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/12 "2021-04-13T07:50:15Z")

</div>

Hi everyone,  
i want to edit header name in my csv file. i have any idea and i cannot find solution in froum. Have any Idea?

Tnx  
Samira

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 April 2021 08:21 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/13 "2021-04-13T08:21:14Z")

</div>

@Samira05 since this thread is two years old please open a new thread and explain what you have tried and show an example. It is not clear if you are already sending column headers and want to change them or if it is something else.

I will close this thread and wait to see your new thread.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 April 2021 08:21 UTC](https://discourse.nodered.org/t/add-column-headers-to-csv-file/15062/14 "2021-04-13T08:21:17Z")

</div>


