# Convert a percentage string (e.g. "99.8%") to Float64 when extracting data from CSV

**URL:** <https://discourse.julialang.org/t/convert-a-percentage-string-e-g-99-8-to-float64-when-extracting-data-from-csv/46278>\
**Category:** New to Julia\
**Created:** [September 8, 2020, 4:50pm UTC](https://discourse.julialang.org/t/convert-a-percentage-string-e-g-99-8-to-float64-when-extracting-data-from-csv/46278 "2020-09-08T16:50:15Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [September 9, 2020, 6:37am UTC](https://discourse.julialang.org/t/convert-a-percentage-string-e-g-99-8-to-float64-when-extracting-data-from-csv/46278/13 "2020-09-09T06:37:33Z")

</div>

Maybe one could write a small package to implement a `Percent` type, and make it possible to do

```julia
parse(Percent{Float64}, "99.5%")

```

Parsing CSV would then work as long as the user specifies which columns should be parsed as this type. A missing “%” at the end of the string would then be a parse error.

(The division by 100 should not happen until converting to another numeric type, since 1//100 is not exactly representable in floating-point.)

---

_[View the full topic](https://discourse.julialang.org/t/convert-a-percentage-string-e-g-99-8-to-float64-when-extracting-data-from-csv/46278)._
