# Multiple separators when importing CSV files in logstash

**URL:** https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722
**Category:** Logstash
**Created:** [April 20, 2019, 5:29pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722 "2019-04-20T17:29:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![flavienbwk](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@flavienbwk](https://discuss.elastic.co/u/flavienbwk)
#### Post date: [April 20, 2019, 5:29pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722/1 "2019-04-20T17:29:56Z")

</div>

Hello,

I have a bunch of CSV files I want to import with each, data of this format :  
`first_name;last_name`

The problem is that sometimes, the format will be :  
`first_name:last_name` (the `;` is `:`)

Is there a way to provide multiple separators in the logstash conf file or will I be forced to process the file before sending it to logstash ?

Maybe it is possible to pass a regular expression in parameter ?

Thank you.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 20, 2019, 6:14pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722/2 "2019-04-20T18:14:35Z")

</div>

If there are only two fields then you could use a grok filter to parse it

```
grok { match => { "message" => "^(?<first>[^:;]+)[:;]%{GREEDYDATA:second}" } }

```

If there are multiple fields it might be better to change the : to ;

```
mutate { gsub => ["message", ":", ";"] }
```

---

<div class="post-metadata">

### Author: ![flavienbwk](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@flavienbwk](https://discuss.elastic.co/u/flavienbwk)
#### Post date: [April 20, 2019, 6:34pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722/3 "2019-04-20T18:34:58Z")

</div>

Thank you for your answer, what about if the second field can contain a ":" or a ";" as its first character ?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 20, 2019, 6:50pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722/4 "2019-04-20T18:50:40Z")

</div>

The grok will still work. It divides the string at the first occurence of either ; or : regardless of what comes after.

---

<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: [May 18, 2019, 6:50pm UTC](https://discuss.elastic.co/t/multiple-separators-when-importing-csv-files-in-logstash/177722/5 "2019-05-18T18:50:41Z")

</div>

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