# Compare a field with a csv file and add info from csv in a new field

**URL:** https://discuss.elastic.co/t/compare-a-field-with-a-csv-file-and-add-info-from-csv-in-a-new-field/191973
**Category:** Logstash
**Created:** [July 24, 2019, 7:49am UTC](https://discuss.elastic.co/t/compare-a-field-with-a-csv-file-and-add-info-from-csv-in-a-new-field/191973 "2019-07-24T07:49:15Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [July 24, 2019, 12:34pm UTC](https://discuss.elastic.co/t/compare-a-field-with-a-csv-file-and-add-info-from-csv-in-a-new-field/191973/2 "2019-07-24T12:34:26Z")

</div>

If file.csv contains

```
11,home
12,garden
13,office

```

then this configuration

```
input { generator { count => 1 lines => [''] } }

filter {
    mutate { add_field => { "id" => "12" } }
    translate {
        field => "[id]"
        destination => "[location]"
        dictionary_path => '/home/file.csv'
        refresh_interval => '1000'
    }
}
output { stdout { codec => rubydebug { metadata => false } } }

```

will produce

```
  "location" => "garden",
        "id" => "12",

```

Your filter should work as is.

---

_[View the full topic](https://discuss.elastic.co/t/compare-a-field-with-a-csv-file-and-add-info-from-csv-in-a-new-field/191973)._
