# Skip header line in CSV input (v 1.5.0)

**URL:** https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386
**Category:** Logstash
**Created:** [May 27, 2015, 12:23pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386 "2015-05-27T12:23:02Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![whittssg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whittssg/32/27669_2.png) [@whittssg](https://discuss.elastic.co/u/whittssg)
#### Post date: [May 27, 2015, 12:23pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/1 "2015-05-27T12:23:02Z")

</div>

Hello,

I am importing some csv files and would like to skip the first line (headers) - at the moment if the csv has headers the lines will fail to import - if i remove the headers they import fine. I did some searching and found that i am supposed to use an if statement with DROP {}:

```
   input {  
      file {
          path => "C:/ElasticSuite/Logs/*.csv"
          type => "mytype"
		  discover_interval => "15"
		  		 		              }
}
filter {  
	csv {
	columns => ["col1", "col2", "col3"]
         separator => ","
    }
	if [col1] == "headername" 
	{
	drop {}
	}	
mutate {
		gsub => ["ipAddress","NA","127.0.0.1"]
		gsub => ["dbLogFileSizeMb","NA","0"]
	  }
	}

```

I tried putting the if below the csv then below the mutate but it still failed.

Any ideas?

Thanks,

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 28, 2015, 7:18am UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/2 "2015-05-28T07:18:54Z")

</div>

Does the drop not work at all?

This general issue has been raised [here](https://github.com/elastic/logstash/issues/2088), but I don't have any other advice sorry.

---

<div class="post-metadata">

### Author: ![whittssg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whittssg/32/27669_2.png) [@whittssg](https://discuss.elastic.co/u/whittssg)
#### Post date: [May 28, 2015, 2:41pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/3 "2015-05-28T14:41:29Z")

</div>

Thanks, I got it working by looking at a sample from within the link that you posted.. I had to had to wrap the column and string within parentheses.

```
if ([col1] == "headername") {
    drop { }
  } 

```

Not sure why most of the samples on the net show it without.

Thanks again

---

<div class="post-metadata">

### Author: ![naisanza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/naisanza/32/44808_2.png) [@naisanza](https://discuss.elastic.co/u/naisanza)
#### Post date: [June 10, 2015, 4:23pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/4 "2015-06-10T16:23:04Z")

</div>

But the bigger question here is still, "How can you have the first row parsed as the column headings, and then dropped during indexing?"

or, "How can you have the first row parsed as the column headings, and then offset the first line from being indexed?"

---

<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 10, 2015, 4:48pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/5 "2015-06-10T16:48:28Z")

</div>

This discussion should be used to promote [https://github.com/elastic/logstash/issues/2088](https://github.com/elastic/logstash/issues/2088), where a solution to this issue is proposed.

---

<div class="post-metadata">

### Author: ![jweite](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jweite](https://discuss.elastic.co/u/jweite)
#### Post date: [August 19, 2015, 9:08pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/6 "2015-08-19T21:08:15Z")

</div>

I too need to process CSV files with first line schemas. Unfortunately the schemas can vary from file to file too.

Not seeing anything out there I got to work and coded up a subclass of logstash-input-file that adds CSV parsing with a first-line-schema mode. The basic CSV processing is largely borrowed from logstash-filter-csv.

Code is at [https://github.com/jweite/logstash-input-csvfile](https://github.com/jweite/logstash-input-csvfile). It's strictly alpha at this stage, but I'd be interested in having it considered for submission.

PS, while I initially considered enhancing logstash-filter-csv I ultimately concluded that the only 100% reliable way to restart stream processing mid-file was to re-read the file's schema row, something that only the file input plugin can always do.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 20, 2015, 1:59am UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/7 "2015-08-20T01:59:03Z")

</div>

It'd be worth you making a new thread so it doesn't get lost 🙂

---

<div class="post-metadata">

### Author: ![jweite](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jweite](https://discuss.elastic.co/u/jweite)
#### Post date: [August 20, 2015, 1:01pm UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/8 "2015-08-20T13:01:43Z")

</div>

Will do, thanks for the tip Mark.

---

<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: [July 6, 2017, 5:31am UTC](https://discuss.elastic.co/t/skip-header-line-in-csv-input-v-1-5-0/1386/9 "2017-07-06T05:31:27Z")

</div>


