# How to escape the double quotes and \\r of csv field from longstash

**URL:** https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884
**Category:** Logstash
**Created:** [July 19, 2016, 2:25pm UTC](https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884 "2016-07-19T14:25:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AnantPatil](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@AnantPatil](https://discuss.elastic.co/u/AnantPatil)
#### Post date: [July 19, 2016, 2:25pm UTC](https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884/1 "2016-07-19T14:25:04Z")

</div>

My csv data is like this:  
S2\_CR\_Browse\_iPhone\_T22\_Click “Cruise&Stay" link from cruise menu,1393,101,46  
Error in Logstash command:  
\<CSV::MalformedCSVError:[Illegal quoting in line 1.\>

My Logstash Filter section:  
filter {  
if([message]=~"sampler\_label" or [message]=~"TOTAL")  
{  
drop{}  
}else{  
csv {  
columns =\> ["label"]  
skip\_empty\_columns =\> true  
}  
}  
}

---

<div class="post-metadata">

### Author: ![PhaedrusTheGreek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phaedrusthegreek/32/4884_2.png) [@PhaedrusTheGreek](https://discuss.elastic.co/u/PhaedrusTheGreek)
#### Post date: [July 19, 2016, 2:58pm UTC](https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884/2 "2016-07-19T14:58:59Z")

</div>

@AnantPatil,

Your input string is illegal CSV format. From the [CSV RFC](https://tools.ietf.org/html/rfc4180):

> Fields containing line breaks (CRLF), double quotes, and commas  
> should be enclosed in double-quotes.

However, as a (hacky) workaround, you could disable the quoting behavior by setting the quote string to some character such as `$` that is not expected to be found in your input.

```auto
  csv {
      columns => ["label", "num1", "num2", "num3"]
      skip_empty_columns => true
      quote_char => "$"
  }

```

---

<div class="post-metadata">

### Author: ![AnantPatil](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@AnantPatil](https://discuss.elastic.co/u/AnantPatil)
#### Post date: [July 19, 2016, 4:03pm UTC](https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884/3 "2016-07-19T16:03:28Z")

</div>

Thank you,will try,

---

<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, 4:47am UTC](https://discuss.elastic.co/t/how-to-escape-the-double-quotes-and-r-of-csv-field-from-longstash/55884/4 "2017-07-06T04:47:23Z")

</div>


