# Import CSV with different column names to same field

**URL:** <https://discuss.elastic.co/t/import-csv-with-different-column-names-to-same-field/223725>\
**Category:** Logstash\
**Created:** [March 16, 2020, 10:00am UTC](https://discuss.elastic.co/t/import-csv-with-different-column-names-to-same-field/223725 "2020-03-16T10:00:03Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Fabio-sama](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@Fabio-sama](https://discuss.elastic.co/u/Fabio-sama)\
**Post date:** [March 16, 2020, 12:35pm UTC](https://discuss.elastic.co/t/import-csv-with-different-column-names-to-same-field/223725/4 "2020-03-16T12:35:14Z")

</div>

Ok so, admitting you have files like the following:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b22b53e59b9f62d29e9aec96d0abe1e942184224.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e349456d184cc12a47707b1cf7fa720523dd3f5c.png)

You can even do a single pipeline like the following:

```
input {
  file {
    path => "/absolute_path_to_file1.csv"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    tags => ["file1"]
  }

  file {
    path => "absolute_path_to_file2.csv"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    tags => ["file2"]
  }
}

filter {
  if "file1" in [tags] {
    csv {
      separator => ","
      columns => ["ID","Date","Name"]
    }

    if [ID] == "ID" {
      drop{}
    }
  } else if "file2" in [tags] {
    csv {
      separator => ","
      columns => ["ID","Ref","Subject","Operator"]
    }

    if [ID] == "Identifier" {
      drop{}
    }
  }
}

output {
  elasticsearch {
    hosts => "localhost:9200"
    index => "test"
    document_id => "%{ID}"
    action => "update"
    doc_as_upsert => true
  }
}

```

This way, you don't even need to rename anything, since you're directly mapping the `Identifier` value to the `ID` field.

In your elasticsearch you'll have something like this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c9e7d9f75bcf83a407816fa6936848d9004e9288.png)

Does this answer to all your questions?

---

_[View the full topic](https://discuss.elastic.co/t/import-csv-with-different-column-names-to-same-field/223725)._
