# Drop first x line from my csv log file

**URL:** https://discuss.elastic.co/t/drop-first-x-line-from-my-csv-log-file/169214
**Category:** Logstash
**Created:** [February 20, 2019, 1:00pm UTC](https://discuss.elastic.co/t/drop-first-x-line-from-my-csv-log-file/169214 "2019-02-20T13:00:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cankaya07](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cankaya07/32/41140_2.png) [@cankaya07](https://discuss.elastic.co/u/cankaya07)
#### Post date: [February 20, 2019, 1:00pm UTC](https://discuss.elastic.co/t/drop-first-x-line-from-my-csv-log-file/169214/1 "2019-02-20T13:00:45Z")

</div>

Hi, i have a csv log file. and i want to parse and send to ES that file via logstash. But my csv file has 3 lines of comment line. Here the shape of my log

```auto
#Version: 15.01.1034.026
#Log-type: Message Tracking Log
#Date: 2018-11-27T17:00:01.234Z
#Fields: csvHeaderColumn1,csvHeaderColumn2
databelongColumn1,databelongColumn2
....

```

i want to drop first three lines which has start with the # and remove "#Fields"  
Actually i can say i want to start my document from csvHeaderColumn1 is there a way to do that with logstash ?

Many thanks

---

<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: [February 20, 2019, 1:10pm UTC](https://discuss.elastic.co/t/drop-first-x-line-from-my-csv-log-file/169214/2 "2019-02-20T13:10:04Z")

</div>

```
    mutate { gsub => ["message", "^#Fields: ", ""] }
    if [message] =~ /^#/ { drop {} }
    csv { autodetect_column_names => true }
```

---

<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: [March 20, 2019, 1:10pm UTC](https://discuss.elastic.co/t/drop-first-x-line-from-my-csv-log-file/169214/3 "2019-03-20T13:10:04Z")

</div>

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