# Parse 1st Line of Multiple CSV files and set as Columns

**URL:** <https://discuss.elastic.co/t/parse-1st-line-of-multiple-csv-files-and-set-as-columns/2246>\
**Category:** Logstash\
**Created:** [June 9, 2015, 6:40pm UTC](https://discuss.elastic.co/t/parse-1st-line-of-multiple-csv-files-and-set-as-columns/2246 "2015-06-09T18:40:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [June 9, 2015, 8:45pm UTC](https://discuss.elastic.co/t/parse-1st-line-of-multiple-csv-files-and-set-as-columns/2246/4 "2015-06-09T20:45:01Z")

</div>

The content is always split into lines, but without a conditional, the csv filter is totally unaware of which line of a file it is receiving. This is why a conditionals are essential, and knowing what the possible column types are.

```
if [csv_type_1] {
  if [message] =~ /headerpattern/ {
    csv { ... }
  }
}

```

csv\_type\_1 identifies a stream (by file type, or whatever you identify it with), headerpattern will be the way you can tell the first line is a header and not data, and then you apply the _known_ csv column match to the data.

Logstash 2.x will simplify this somewhat as we are designing it to allow for multiple pipelines. A (hypothetical) CSV pipeline would allow for ingesting a single file, and using the first line to define column/field names. In the meanwhile, unfortunately there is nothing in Logstash which will do what you are asking.

---

_[View the full topic](https://discuss.elastic.co/t/parse-1st-line-of-multiple-csv-files-and-set-as-columns/2246)._
