How convert String to Float64

How convert Chr to Float64

Version 0.4.5 (2016-03-18 00:58 UTC)
Official http://julialang.org/ release
x86_64-w64-mingw32

julia> HH_baza[1,4]
“4385.37”

julia> eltype(HH_baza[1,4])
Char

julia> convert(Float64,HH_baza[1,4])
ERROR: MethodError: convert has no method matching convert(::Type{Float64}, ::UTF8String)
This may have arisen from a call to the constructor Float64(…),
since type constructors fall back to convert methods.
Closest candidates are:
call{T}(::Type{T}, ::Any)
convert(::Type{Float64}, ::Int8)
convert(::Type{Float64}, ::Int16)

Paul

You answered yourself in your other thread: use parse.
Note that this is not of type Char (bit Chr), but String.

julia> parse(Float64, "122.2")
122.2
4 Likes

In future, please provide a minimal example that other people can actually run.

One problem is that you are using eltype instead of typeof.
A String is viewed as a collection of type Char, which is why you get that result from eltype(HH_baza[1,4])

julia> eltype(HH_baza[1,4])
Char

Are you asking why eltype returns Char?
Just to restate previous replies (this on v0.4.5):

julia> eltype("4385.37")
Char

julia> typeof("4385.37")
ASCIIString

julia> parse(Float64, "4385.37")
4385.37
1 Like