It seems like you have a bunch of null characters in the string for some 
reason. You could try stripping them out with replace:

julia> x = "\x002\0.\x005\0"

"\x002\0.\x005\0"


julia> y = replace(x,"\0","")

"2.5"


julia> parse(Float64, y)

2.5




On Tuesday, 25 October 2016 05:44:34 UTC+1, Chris Stook wrote:
>
> I'm trying to parse a text file which contains some floating point 
> numbers.  The number 2.5 is represented by the string "\x002\0.\x005\0". 
>  Parse will not convert this to a Float64.  Print works (prints "2.5") in 
> Atom and Jupyter, but not in the REPL.
>
> _
> _       _ _(_)_     |  A fresh approach to technical computing
> (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
> _ _   _| |_  __ _   |  Type "?help" for help.
> | | | | | | |/ _` |  |
> | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
> _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
> |__/                   |  x86_64-w64-mingw32
>
> julia> print("\x002\0.\x005\0")
> �2�.�5�
> julia> parse(Float64,"\x002\0.\x005\0")
> ERROR: ArgumentError: invalid number format "\x002\0.\x005\0" for Float64
> in parse(::Type{Float64}, ::String) at .\parse.jl:167
>
> julia>
>
> I am not familiar with Unicode.  Is the Unicode valid?  How should I 
> convert this to a Float?  I do not have control over the input file.
>
> Thanks,
> Chris
>
>

Reply via email to