# Multiple CSV files, Multiple Header data

**URL:** <https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150>\
**Category:** Logstash\
**Created:** [April 21, 2017, 6:22am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150 "2017-04-21T06:22:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [April 21, 2017, 6:22am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150/1 "2017-04-21T06:22:13Z")

</div>

Hi,  
I am using multiple csv input files  
with locations  
_/user/location2/consumption-\*.csv_  
_/user/location2/maps\*.csv_

Now in my logstash configuration i want to use conditional basis the **path of csv files**  
input  
{  
file  
{  
path =\> [ "/user/location2/maps\*.csv",  
"/user/location2/consumption-\*.csv"  
]  
start\_position =\> "beginning"  
# sincedb\_path =\> "/user/somelocation/.sincedb"  
}  
}  
filter {

```
if [path] == "/user/location2/maps*.csv"
{
csv {
        columns => [A,B,C,D]
        separator => ","
}
}
else if [path] == "/user/location2/consumption*.csv"
{
csv {
 columns => [A,E,F,G]
separator => ","
}
}

```

However I am not able to get the data pushed to elasticsearch

---

<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:** [April 21, 2017, 6:26am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150/2 "2017-04-21T06:26:27Z")

</div>

The `path` field will contain the actual path to the file, not the wildcard you used in the file input's `path` option. You can use a regular expression match conditional (see documentation) to check whether the `path` field matches a pattern.

But... I think it would be cleaner to split your single file input into two file inputs that set a tag or a particular field to indicate what kind of data it is. Then you can use a simple conditional on that tag or field to decide which filtes to apply.

---

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [April 21, 2017, 6:37am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150/3 "2017-04-21T06:37:10Z")

</div>

Thanks Magnus,

So let me use this configuration input

```
input
{
file
{
path => "/user/location2/maps.csv"
start_position => "beginning"
#sincedb_path => "/user/somelocation/.sincedb"
}
file
 {
path => "/user/location2/consumption_data*.csv"
start_position => "beginning"
# sincedb_path => "/user/somelocation/.sincedb"
}
}
filter {
if [path] == "/user/location2/maps.csv"
{
csv {
        columns => [A,B,C,D]
        separator => ","
}
}
else if [path] == "/user/location2/consumption_data1.csv" , "/user/location2/consumption_data2.csv"
{
csv {
 columns => [A,E,F,G]
separator => ","
}
}

```

Will this work

---

<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:** [April 21, 2017, 7:30am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150/4 "2017-04-21T07:30:55Z")

</div>

> ```
> else if [path] == "/user/location2/consumption_data1.csv" , "/user/location2/consumption_data2.csv"
> 
> ```

This won't work, you need this:

> ```
> else if [path] == "/user/location2/consumption_data1.csv" or [path] == "/user/location2/consumption_data2.csv"
> 
> ```

Better yet, use a regular expression match.

But again, you should really be setting a tag or a field at the input.

---

<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:** [May 19, 2017, 7:36am UTC](https://discuss.elastic.co/t/multiple-csv-files-multiple-header-data/83150/5 "2017-05-19T07:36:17Z")

</div>

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