# Substituting Value of a Field to a Mapping from a CSV file

**URL:** https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709
**Category:** Logstash
**Created:** [August 3, 2015, 7:52am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709 "2015-08-03T07:52:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jasonct05](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jasonct05](https://discuss.elastic.co/u/jasonct05)
#### Post date: [August 3, 2015, 7:52am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709/1 "2015-08-03T07:52:37Z")

</div>

I have used logstash's xpath filter to parse an xml file and get a specified attribute. However, I would like to replace this value to another value based on the mapping of a separated CSV file.

For example, I have used logstash to parse my log's "id3" attribute to get the value "000000" stored in the "Merchant Name" field. I would then want logstash to replace this value by comparing this to a separated csv file with the following lines of code

```
  ID,MERCHANT NAME
  000000,Store 1
  000001,Store 2
  000002,Store 3

```

After the comparison, i would like logstash to map the "Merchant Name" field to "Store 1" instead of "000000". If the mapped "id3" value is "000002", then I would like logstash to map the "Merchant Name" field to "Store 2".

Any help would be much appreciated.

Best,  
Jason Tan

---

<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: [August 3, 2015, 7:53am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709/2 "2015-08-03T07:53:28Z")

</div>

Have you seen the translate filter, it should do what you want.

---

<div class="post-metadata">

### Author: ![jasonct05](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jasonct05](https://discuss.elastic.co/u/jasonct05)
#### Post date: [August 4, 2015, 3:33am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709/3 "2015-08-04T03:33:17Z")

</div>

Yes I have seen the Translate Filter. However, as far as i know, it only works for YML files. Is there a filter that can work for CSV files?

Thanks.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 4, 2015, 4:59am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709/4 "2015-08-04T04:59:06Z")

</div>

Why not transform your CSV file into YML and use the translate plugin? I am not aware of any similar filter that works with CSV files.

---

<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:33am UTC](https://discuss.elastic.co/t/substituting-value-of-a-field-to-a-mapping-from-a-csv-file/26709/5 "2017-07-06T05:33:02Z")

</div>


