# Add field with logstash in csv file

**URL:** https://discuss.elastic.co/t/add-field-with-logstash-in-csv-file/84919
**Category:** Logstash
**Created:** [May 8, 2017, 10:54am UTC](https://discuss.elastic.co/t/add-field-with-logstash-in-csv-file/84919 "2017-05-08T10:54:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zegdene](https://avatars.discourse-cdn.com/v4/letter/z/76d3ee/32.png) [@zegdene](https://discuss.elastic.co/u/zegdene)
#### Post date: [May 8, 2017, 10:54am UTC](https://discuss.elastic.co/t/add-field-with-logstash-in-csv-file/84919/1 "2017-05-08T10:54:50Z")

</div>

Hi,  
I create a file config.conf to insert data.csv in elasticsearch  
i need to remove filed and add in empty filed  
this is my config.conf:

```
input {
  file {
    path => "/home/salma/Documents/data.csv"
    start_position => "beginning"
   sincedb_path => "/dev/null"
  }
}
filter {
  csv {
      separator => ","
#Date,Open,High,Low,Close,Volume (BTC),Volume (Currency),Weighted Price
     columns => ["Open","High","Low","Close","Volume (BTC)", "Volume (Currency)" ,"Weighted Price"]
  }
mutate {
    add_field => { "foo_%{pred}"}
  }
}
output {
   elasticsearch {
     hosts => "http://localhost:9200"
     index => "bitcoin-prices"
  }
stdout {}
}

```

but nothing change in elastcsearch  
can help please  
thank you!

---

<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: [May 8, 2017, 12:08pm UTC](https://discuss.elastic.co/t/add-field-with-logstash-in-csv-file/84919/2 "2017-05-08T12:08:08Z")

</div>

> ```
> add_field => { "foo_%{pred}"}
> 
> ```

`add_field` needs two things: the name of the new field and its desired value. It should look like this:

```plaintext
add_field => {
  "field name" => "field value"
}

```

Secondly, `%{pred}` doesn't make sense since your events don't have a field named `pred`.

---

<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 5, 2017, 12:21pm UTC](https://discuss.elastic.co/t/add-field-with-logstash-in-csv-file/84919/3 "2017-06-05T12:21:25Z")

</div>

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