# Restrict Logstash to map values to its specific Columns Using CSV filter

**URL:** <https://discuss.elastic.co/t/restrict-logstash-to-map-values-to-its-specific-columns-using-csv-filter/59303>\
**Category:** Logstash\
**Created:** [August 30, 2016, 12:11pm UTC](https://discuss.elastic.co/t/restrict-logstash-to-map-values-to-its-specific-columns-using-csv-filter/59303 "2016-08-30T12:11:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthikeyan95](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@karthikeyan95](https://discuss.elastic.co/u/karthikeyan95)\
**Post date:** [August 30, 2016, 12:11pm UTC](https://discuss.elastic.co/t/restrict-logstash-to-map-values-to-its-specific-columns-using-csv-filter/59303/1 "2016-08-30T12:11:16Z")

</div>

Hi everyone,  
I am trying to store data from CSV files into Elasticsearch using Logstash.  
i have a logstash configuration using the csv filter containing columns say  
`csv{ columns => ["A", "B", "C","D","E"] seperator => "," skip_empty_columns => true }`  
and say if my CSV file has columns [B,C,D,E] and values for it ie, there is no column named "A".  
Eg file:

> B,C,D,E,  
> 1,2,3,4,

when i run my Logstash with this particular configuration, what happens is that Logstash stores data in Elasticsearch this way.

> A=1  
> B=2  
> C=3  
> D=4

Column E does not get stored, Since i have given the option of  
`skip_empty_columns => true`  
Column "E" is omitted.

But i want my data to be stored in Elasticsearch in this way

> B=1  
> C=2  
> D=3  
> E=4

ie, i want the data to correctly map to the particular Column even though there are other columns configured.  
I am looking for a solution where Logstash has to take values and map them to the respective Column and not in some order.  
Can anyone suggest a solution for this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 4, 2016, 7:44pm UTC](https://discuss.elastic.co/t/restrict-logstash-to-map-values-to-its-specific-columns-using-csv-filter/59303/2 "2016-09-04T19:44:57Z")

</div>

I'd say your CSV files are broken. If the A column doesn't have a value I'd expect the line to begin with a comma.

> I am looking for a solution where Logstash has to take values and map them to the respective Column and not in some order.

How would Logstash know which column values map to which column names, if the data doesn't follow the column configuration?

---

<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, 4:40am UTC](https://discuss.elastic.co/t/restrict-logstash-to-map-values-to-its-specific-columns-using-csv-filter/59303/3 "2017-07-06T04:40:00Z")

</div>


