# Logstash CSV parse Failure

**URL:** <https://discuss.elastic.co/t/logstash-csv-parse-failure/69963>\
**Category:** Logstash\
**Created:** [December 25, 2016, 3:22pm UTC](https://discuss.elastic.co/t/logstash-csv-parse-failure/69963 "2016-12-25T15:22:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_agrawal/32/74982_2.png) [@Prashant\_Agrawal](https://discuss.elastic.co/u/Prashant_Agrawal)\
**Post date:** [December 25, 2016, 3:22pm UTC](https://discuss.elastic.co/t/logstash-csv-parse-failure/69963/1 "2016-12-25T15:22:50Z")

</div>

Hi All,  
I have a log file which I need to parse using logstash but somehow I am stuck parsing the same. The use case is

I have a log file which has entries separated with ||| and message also has " in it. So while parsing with CSV its giving parsing exception ,

Sample entries in log file as test.txt:

> "1"|||"somthing here"|||"somthing with " in here"|||"just for fun"  
> "2"|||"somthing here"|||"somthing with " in here"|||"just for fun"  
> "3"|||"somthing here"|||"somthing with " in here"|||"just for fun"

And logstash conf as :

> ```
> input {
> file {
> path => ["/home/ubuntu/test.txt"]
> }
> }
> filter {
> csv {
> separator => "|||"
> }
> }
> output {
> stdout { codec => rubydebug }
> }
> 
> ```

> The catch is I am fine doing gsub """ with "" , but I want to preserve the " which is in fields 3 as something with " in here"

Thanks!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 15, 2017, 4:26pm UTC](https://discuss.elastic.co/t/logstash-csv-parse-failure/69963/2 "2017-01-15T16:26:53Z")

</div>

Perhaps you can use a mutate filter and its split option to split on the `|||`, then use gsub to remove leading and trailing double quotes?

---

<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:** [February 12, 2017, 4:27pm UTC](https://discuss.elastic.co/t/logstash-csv-parse-failure/69963/3 "2017-02-12T16:27:15Z")

</div>

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