# Date and number format

**URL:** <https://discuss.elastic.co/t/date-and-number-format/53323>\
**Category:** Logstash\
**Created:** [June 20, 2016, 2:14pm UTC](https://discuss.elastic.co/t/date-and-number-format/53323 "2016-06-20T14:14:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mat17](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@mat17](https://discuss.elastic.co/u/mat17)\
**Post date:** [June 20, 2016, 2:14pm UTC](https://discuss.elastic.co/t/date-and-number-format/53323/1 "2016-06-20T14:14:52Z")

</div>

Hello,  
I'm trying to integrate a csv files but i have troubles with date and number format.

Files contain the information below  
2016-06-01,xxxxx,AD,NA,4.31  
....

I use the csv filter to collect datas then i try to add a new field and convert it to a number.  
1/ The conversion "string to float" gave me always a number = 0.  
2/ I don't find the right way to parse the date with the format "yyyy-mm-dd" in order to match @timestamp

########################################  
if [type] == "rating\_country" {

```
    csv {

        #Date,Package Name,Country,Daily Average Rating,Total Average Rating
        columns => ["timevalue", "PackageName","Country","DailyAverageRating","TotalAverageRating"]
        separator => ","
    }

    mutate {
      add_field => {"TotalAverageRatingFloat" => ["%{TotalAverageRating}"]}
    }

    mutate {
      convert => { "TotalAverageRatingFloat" => "float" }
    }

    date {
        match => ["timevalue", "yyyy-MM-dd HH:mm:ss"]
    }

}

```

########################################

The data into elasticsearch  
{  
"\_index": "rating\_country-2016.06.20",  
"\_type": "rating\_country",  
"\_id": "AVVuGrov59dQgZAfvsI0",  
"\_version": 1,  
"\_score": 1,  
"\_source": {  
"message": "2016-06-01,xxxxxx,AD,NA,4.31",  
"@version": "1",  
"@timestamp": "2016-06-20T13:58:12.717Z",  
"path": "/Users/Mathieu/Documents/logs/market/stats/ratings/ratings\_xxxxx\_201606\_country.csv",  
"host": "BTWNMCPS061",  
"type": "rating\_country",  
"timevalue": "2016-06-01",  
"PackageName": "xxxxxx",  
"Country": "AD",  
"DailyAverageRating": "NA",  
"TotalAverageRating": "4.31",  
"TotalAverageRatingFloat": 0  
}  
}

---

<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:** [June 21, 2016, 6:00am UTC](https://discuss.elastic.co/t/date-and-number-format/53323/2 "2016-06-21T06:00:55Z")

</div>

> ```
> match => ["timevalue", "yyyy-MM-dd HH:mm:ss"]
> 
> ```

This doesn't match your timestamps. You have no time in them, so remove " HH:mm:ss".

> ```
> add_field => {"TotalAverageRatingFloat" => ["%{TotalAverageRating}"]}
> 
> ```

Unless you want `TotalAverageRatingFloat` to become an array I suggest you drop the square brackets. The mutate filter's convert option should deal with arrays too though.

---

<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:51am UTC](https://discuss.elastic.co/t/date-and-number-format/53323/3 "2017-07-06T04:51:36Z")

</div>


