# Logstash out put csv with header

**URL:** <https://discuss.elastic.co/t/logstash-out-put-csv-with-header/239968>\
**Category:** Logstash\
**Created:** [July 6, 2020, 7:41am UTC](https://discuss.elastic.co/t/logstash-out-put-csv-with-header/239968 "2020-07-06T07:41:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)\
**Post date:** [July 6, 2020, 7:41am UTC](https://discuss.elastic.co/t/logstash-out-put-csv-with-header/239968/1 "2020-07-06T07:41:22Z")

</div>

I am trying to create a csv file by using the output csv in logstash.  
How can I insert the header only once at the very beginning?

my data:

```auto
    es_field1 es_field2 es_field3
    1 2 3
    4 5 6
    7 8 9

```

logstash config:

```auto
    output {
     path => "/my/path/to/csv"
     csv_options => {
      "write_headers" => true
      "hearders" => "a,b,c"
     } 
     fields => ["es_field1", "es_field", "es_field"]
    }

```

result:

```auto
    a b c
    1 2 3
    a b c 
    4 5 6
    a b c 
    7 8 9 

```

Headers are inserted for each row.  
How can I insert the header only once at the very beginning?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 6, 2020, 4:54pm UTC](https://discuss.elastic.co/t/logstash-out-put-csv-with-header/239968/2 "2020-07-06T16:54:27Z")

</div>

> [@Yungyoung\_Ok](#):
>
> How can I insert the header only once at the very beginning?

You cannot make the csv output do that. It is an [open issue](https://github.com/logstash-plugins/logstash-output-csv/issues/8).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 3, 2020, 4:54pm UTC](https://discuss.elastic.co/t/logstash-out-put-csv-with-header/239968/3 "2020-08-03T16:54:29Z")

</div>

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