Julia: Convert numeric string to float or int

Use parse(Float64,"1").

See more at: parse specification


You can parse(Float64,"1") from a string. Or in the case of a vector

map(x->parse(Float64,x),stringvec)

will parse the whole vector.

BTW consider using tryparse(Float64,x) instead of parse. It returns a Nullable{Float64} which is null in the case string doesn't parse well. For example:

isnull(tryparse(Float64,"33.2.1")) == true

And usually one would want a default value in case of a parse error:

strvec = ["1.2","NA","-1e3"]
map(x->(v = tryparse(Float64,x); isnull(v) ? 0.0 : get(v)),strvec)
# gives [1.2,0.0,-1000.0]