# Combine Two csv fileds using key column in logstash/Elasticsearch

**URL:** <https://discuss.elastic.co/t/combine-two-csv-fileds-using-key-column-in-logstash-elasticsearch/233677>\
**Category:** Elasticsearch\
**Created:** [May 21, 2020, 6:44am UTC](https://discuss.elastic.co/t/combine-two-csv-fileds-using-key-column-in-logstash-elasticsearch/233677 "2020-05-21T06:44:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![renu\_jessi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renu_jessi/32/55702_2.png) [@renu\_jessi](https://discuss.elastic.co/u/renu_jessi)\
**Post date:** [May 21, 2020, 6:44am UTC](https://discuss.elastic.co/t/combine-two-csv-fileds-using-key-column-in-logstash-elasticsearch/233677/1 "2020-05-21T06:44:37Z")

</div>

Hi,

I have two csv files like below

CSV1 :  
ID,Number,Name,Gender  
100,CHG0032798,Thor,Male

CSV2 :  
ID.Drop  
100,drop1

ISSUE:  
I need to combine this csv fileds make it as one index like below  
**ID Number Gender Drop**

I have trield scroll api,ruby in logstash but failed.  
can u pls help the way to achieve this

---

<div class="post-metadata">

**Author:** ![renu\_jessi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renu_jessi/32/55702_2.png) [@renu\_jessi](https://discuss.elastic.co/u/renu_jessi)\
**Post date:** [May 29, 2020, 5:32am UTC](https://discuss.elastic.co/t/combine-two-csv-fileds-using-key-column-in-logstash-elasticsearch/233677/2 "2020-05-29T05:32:19Z")

</div>

I got the solution by using ruby filter plugin..if any one searching for it pls find the solution below.

ruby { code =\> '  
require "csv"  
CSV.foreach("csv2.csv") do |rec|  
if rec[0] == event.get("")  
event.set("",rec[1])  
end  
end   
' }

---

<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:** [June 26, 2020, 5:32am UTC](https://discuss.elastic.co/t/combine-two-csv-fileds-using-key-column-in-logstash-elasticsearch/233677/3 "2020-06-26T05:32:23Z")

</div>

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