# How to drop a line if it does not have all fields in it?

**URL:** <https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090>\
**Category:** Logstash\
**Created:** [September 3, 2018, 2:18pm UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090 "2018-09-03T14:18:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas\_gopal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_gopal/32/47661_2.png) [@vikas\_gopal](https://discuss.elastic.co/u/vikas_gopal)\
**Post date:** [September 3, 2018, 2:18pm UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090/1 "2018-09-03T14:18:49Z")

</div>

Hi Experts,

I have csv file and it has 4 columns , unfortunately it has data like  
"abc", "123", "res","vg"  
"abc", "123", "res","vg"  
"abc", "123", "res  
"abc", "123", "res  
"abc", "123", "res","vg"  
"abc", "123", "res","vg"

Now everything works fine with csv filter but problem is with line number 3 and 4

1. it does not have all 4 fields
2. Line is ending with "res

I want to drop all the lines which ends with "res , please suggest how I can achieve this

I tried following methods but getting same

```
if [message] == '"res\n'
{
drop { }
}

if [message] == 'res\n'
    {
    drop { }
    }

if [message] == '("res\n)'
{
drop { }
}

```

\*\*In both the Cases Error is same \*\*

> :exception=\>#\<CSV::MalformedCSVError: Unclosed quoted field on line 1.\>

`

Regards  
VG

---

<div class="post-metadata">

**Author:** ![vikas\_gopal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_gopal/32/47661_2.png) [@vikas\_gopal](https://discuss.elastic.co/u/vikas_gopal)\
**Post date:** [September 10, 2018, 7:48am UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090/2 "2018-09-10T07:48:59Z")

</div>

Anyone ?

---

<div class="post-metadata">

**Author:** ![JPelastic](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@JPelastic](https://discuss.elastic.co/u/JPelastic)\
**Post date:** [September 10, 2018, 9:10am UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090/4 "2018-09-10T09:10:42Z")

</div>

Hi Vikas

can you give the total config file?

Thanks

---

<div class="post-metadata">

**Author:** ![vikas\_gopal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_gopal/32/47661_2.png) [@vikas\_gopal](https://discuss.elastic.co/u/vikas_gopal)\
**Post date:** [September 10, 2018, 1:15pm UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090/5 "2018-09-10T13:15:52Z")

</div>

Never mind below works like a charm

> if [message] == "res/\n"  
> {  
> drop {}
> 
> }

---

<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:** [October 8, 2018, 1:15pm UTC](https://discuss.elastic.co/t/how-to-drop-a-line-if-it-does-not-have-all-fields-in-it/147090/6 "2018-10-08T13:15:54Z")

</div>

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