# Replace special characters in csv header

**URL:** <https://discuss.elastic.co/t/replace-special-characters-in-csv-header/202571>\
**Category:** Logstash\
**Created:** [October 7, 2019, 4:49pm UTC](https://discuss.elastic.co/t/replace-special-characters-in-csv-header/202571 "2019-10-07T16:49:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarvis5181](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jarvis5181](https://discuss.elastic.co/u/jarvis5181)\
**Post date:** [October 7, 2019, 4:49pm UTC](https://discuss.elastic.co/t/replace-special-characters-in-csv-header/202571/1 "2019-10-07T16:49:27Z")

</div>

Hello,  
I have a csv file with a header row which contains the special characters "[" and "]" in few of the column names. Logstash issues the exception "#\<RuntimeError: Invalid FieldReference:" while attempting to parse it. Is there anyway to overcome this through logstash?

Any help would be much appreciated!  
Thanks!

---

<div class="post-metadata">

**Author:** ![jarvis5181](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@jarvis5181](https://discuss.elastic.co/u/jarvis5181)\
**Post date:** [October 7, 2019, 5:05pm UTC](https://discuss.elastic.co/t/replace-special-characters-in-csv-header/202571/2 "2019-10-07T17:05:19Z")

</div>

I was able to resolve this with the mutate - gsub filter.  
In my first attempt, I placed the mutate filter after the csv filter and it did not work.  
I changed the order now and it works like a charm!

---

<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:** [November 4, 2019, 5:05pm UTC](https://discuss.elastic.co/t/replace-special-characters-in-csv-header/202571/3 "2019-11-04T17:05:33Z")

</div>

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