# Reading the heading (1st line) of CSV file through logstash

**URL:** <https://discuss.elastic.co/t/reading-the-heading-1st-line-of-csv-file-through-logstash/108930>\
**Category:** Logstash\
**Created:** [November 23, 2017, 5:53pm UTC](https://discuss.elastic.co/t/reading-the-heading-1st-line-of-csv-file-through-logstash/108930 "2017-11-23T17:53:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [November 24, 2017, 11:34am UTC](https://discuss.elastic.co/t/reading-the-heading-1st-line-of-csv-file-through-logstash/108930/6 "2017-11-24T11:34:15Z")

</div>

As @BinaryMonkey has suggested you can **try** the setting the first or both of:

```auto
autodetect_column_names => true
autogenerate_column_names => true

```

See [https://github.com/logstash-plugins/logstash-filter-csv/blob/master/lib/logstash/filters/csv.rb#L126](https://github.com/logstash-plugins/logstash-filter-csv/blob/master/lib/logstash/filters/csv.rb#L126)  
The line of code above will capture the first event seen by the plugin (on all LS restarts) as the column names.

The real pitfall with this is:

1. Only the very first line of the very first file will be the columns for all other files - because the CSV filter does not keep a map of file\_path -\> columns internally.
2. If you have to restart Logstash while it is half way though a file then the first line of that file will not be re-read and the columns will become some arbitrary set of values.

---

_[View the full topic](https://discuss.elastic.co/t/reading-the-heading-1st-line-of-csv-file-through-logstash/108930)._
