# How to put headers only once in a csv file

**URL:** <https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875>\
**Category:** General\
**Created:** [20 May 2022 07:16 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875 "2022-05-20T07:16:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 May 2022 07:16 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/1 "2022-05-20T07:16:42Z")

</div>

Hello,

I would like to know if it's possible to add juste one time the row of headers in a csv file with the csv node beaucause I don't find how to do it without programming a function ... is there another way ?

Here is my subflow :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/edfe5de74d031403b857abf03fcb0157e1ee2217.png)

And here is my payload and the output of my csv node :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97c39d15d0c264e432cf4fb93102d30bf88e90e3.png)

So I would like to have only one time the description of my values and not at each shipment of my sensor.

Thanks

---

<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:** [20 May 2022 07:49 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/2 "2022-05-20T07:49:37Z")

</div>

There is an option in the csv node to send headers once or not send headers.

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 May 2022 08:17 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/3 "2022-05-20T08:17:33Z")

</div>

Yes you can send it or not but when you choose to send it, for each payload you have the headers back.

---

<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:** [20 May 2022 08:19 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/4 "2022-05-20T08:19:51Z")

</div>

if you pick option to send once, it will only add header the first time it runs.

or

don't send header and add the header to the csv file to start with.

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 May 2022 08:32 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/5 "2022-05-20T08:32:16Z")

</div>

I have just these options for my csv node :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c21df443464537580b0efa865115eed6de253caa.png)

And when you say to add header to teh csv file to start with how you know when it start ?

Before I used an exec node to write in the csv file and I used some flag to know if it's the beggining of my file or not.

---

<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:** [20 May 2022 08:50 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/6 "2022-05-20T08:50:50Z")

</div>

You are probably running on an old version, if you want the settings I suggest you update node-red.

when i say add header to csv at start, I mean create the csv file and add the header manually, or use the file nodes to check for file, if it does not exist create it with header on first line.

---

<div class="post-metadata">

**Author:** ![nke9](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nke9/32/46752_2.png) [@nke9](https://discourse.nodered.org/u/nke9)\
**Post date:** [20 May 2022 10:14 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/7 "2022-05-20T10:14:11Z")

</div>

Ok thanks for your help, I'm going to look for solutions with your response.

---

<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:** [3 June 2022 10:14 UTC](https://discourse.nodered.org/t/how-to-put-headers-only-once-in-a-csv-file/62875/8 "2022-06-03T10:14:44Z")

</div>

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