# Convert STRING to FLOAT through FluentD using csv plugin

**URL:** <https://discuss.elastic.co/t/convert-string-to-float-through-fluentd-using-csv-plugin/217974>\
**Category:** Kibana\
**Created:** [February 5, 2020, 11:09am UTC](https://discuss.elastic.co/t/convert-string-to-float-through-fluentd-using-csv-plugin/217974 "2020-02-05T11:09:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![King\_D](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@King\_D](https://discuss.elastic.co/u/King_D)\
**Post date:** [February 5, 2020, 11:09am UTC](https://discuss.elastic.co/t/convert-string-to-float-through-fluentd-using-csv-plugin/217974/1 "2020-02-05T11:09:25Z")

</div>

I need help with converting a string field to float either by modifying td-agent.conf file or by scripted field but seem to be failing miserably.

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [February 5, 2020, 7:39pm UTC](https://discuss.elastic.co/t/convert-string-to-float-through-fluentd-using-csv-plugin/217974/2 "2020-02-05T19:39:28Z")

</div>

For the scripted fields, you could do something like?

```auto
if (doc['stringnumber'].empty) { 
    return "0" 
} else { 
    return Double.parseDouble(doc['stringnumber'].value); 
}

```

---

<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:** [March 4, 2020, 7:39pm UTC](https://discuss.elastic.co/t/convert-string-to-float-through-fluentd-using-csv-plugin/217974/3 "2020-03-04T19:39:35Z")

</div>

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