# Replacing the very last comma in a csv file

**URL:** <https://discuss.elastic.co/t/replacing-the-very-last-comma-in-a-csv-file/61444>\
**Category:** Logstash\
**Created:** [September 24, 2016, 5:26pm UTC](https://discuss.elastic.co/t/replacing-the-very-last-comma-in-a-csv-file/61444 "2016-09-24T17:26:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Logstash-lover](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@Logstash-lover](https://discuss.elastic.co/u/Logstash-lover)\
**Post date:** [September 24, 2016, 5:26pm UTC](https://discuss.elastic.co/t/replacing-the-very-last-comma-in-a-csv-file/61444/1 "2016-09-24T17:26:06Z")

</div>

Im processing various .csv files thru logstash using windows. I noticed if the csv file contains a comma at the very end of the very last line, logstash seems to pause on this .csv file and not proceed to process the csv file. When i manually remove this very last comma in the last line, then Logstash will process it for indexing.

Is this a known behavior of Logstash? If so, how do i grep for and place the last line and end of line orphan comma of a .csv file? I have experimented with filter section of logstash conf file and using mutate, gsub to achieve this with no luck. Am i on the right track? I will post relevant parts of conf file, if so.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 25, 2016, 6:17am UTC](https://discuss.elastic.co/t/replacing-the-very-last-comma-in-a-csv-file/61444/2 "2016-09-25T06:17:19Z")

</div>

Basically it is waiting for the next field to fill the columns you have defined.  
There isn't a good way to get around this unfortunately.

---

<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:37am UTC](https://discuss.elastic.co/t/replacing-the-very-last-comma-in-a-csv-file/61444/3 "2017-07-06T04:37:07Z")

</div>


