# Error While Parsing CSV file

**URL:** <https://discuss.elastic.co/t/error-while-parsing-csv-file/2090>\
**Category:** Logstash\
**Created:** [June 7, 2015, 3:31pm UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090 "2015-06-07T15:31:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vicky\_aquarian](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@Vicky\_aquarian](https://discuss.elastic.co/u/Vicky_aquarian)\
**Post date:** [June 7, 2015, 3:31pm UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090/1 "2015-06-07T15:31:22Z")

</div>

Hi,  
I'm using logstash ver logstash-1.5.0.rc2 and trying to parse log files containing lines like :

2015-02-03 06:10:38.6024|MEMSGSERVER|Trace|WcfMessageInspector|14|52e46324-a775-4a91-96d6-7efd3763cf88|END SERVICE REQUEST

Lines have several fields separated by | so trying to parse thru csv filter using config like  
Config:

input {

file {

```
path => "/home/mohan/Downloads/Logs/srlog.log"

start_position => beginning

```

}

}  
filter{  
csv {  
columns =\> ["mytime" , "server" , "event\_sev" , "component" , "event\_id" , "event\_code" , "event\_message"]  
separator =\> "|"  
}  
}

output {  
stdout { }  
}

I'm getting error : Trouble parsing csv {:source=\>"message", :raw=\>"", :exception=\>#\<NoMethodError: undefined method `each\_index' for nil:NilClass\>, :level=\>:warn}

When I slightly change columns like :  
filter{  
csv {  
columns =\> ["@timestamp" , "server" , "event\_sev" , "component" , "event\_id" , "event\_code" , "event\_message"]  
separator =\> "|"  
}

I get error :  
Trouble parsing csv {:source=\>"message", :raw=\>"2015-02-03 06:10:38.6024|MEMSGSERVER|Trace|WcfMessageInspector|14|52e46324-a775-4a91-96d6-7efd3763cf88|END SERVICE REQUEST ", :exception=\>#\<TypeError: The field '@timestamp' must be a (LogStash::Timestamp, not a String (2015-02-03 06:10:38.6024)\>, :level=\>:warn}

Please help me and let me know if I'm missing something??

-Thanks in Advance

---

<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:** [June 7, 2015, 3:39pm UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090/2 "2015-06-07T15:39:18Z")

</div>

> I'm getting error : Trouble parsing csv {:source=\>"message", :raw=\>"", :exception=\>#, :level=\>:warn}

I believe the "raw" value is the string that it tried to parse, so it looks like there was an empty string in the input file.

Don't try to parse CSV directly into the `@timestamp` field.

---

<div class="post-metadata">

**Author:** ![Vicky\_aquarian](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@Vicky\_aquarian](https://discuss.elastic.co/u/Vicky_aquarian)\
**Post date:** [June 8, 2015, 5:28pm UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090/3 "2015-06-08T17:28:43Z")

</div>

Hi,

Thanks for your reply..

Exact message is :  
Trouble parsing csv {:source=\>"message", :raw=\>"2015-02-03 19:54:34.5477|DCAOTSERVER|Trace|Workflow.S2R|5||Key Active Start Time: 2/3/2015 2:45:00 PM, Key Active End Time: 2/5/2015 2:00:00 PM ", :exception=\>#\<TypeError: The field '@timestamp' must be a (LogStash::Timestamp, not a String (2015-02-03 19:54:34.5477)\>, :level=\>:warn}

What could be the issue?? Is there any way to parse the time in @timestamp?

-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:** [June 8, 2015, 8:10pm UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090/4 "2015-06-08T20:10:14Z")

</div>

Again, don't try to parse CSV directly into the `@timestamp` field. Have the csv filterstore the timestamp in a temporary field (call it `timestamp` or whatever) and use the [date filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) to parse that field and store the result in the `@timestamp` field.

---

<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:38am UTC](https://discuss.elastic.co/t/error-while-parsing-csv-file/2090/5 "2017-07-06T05:38:08Z")

</div>


