I have saved some data in Julia without any thought for formatting it. The saved file look something like the following;
([0.123, 0.124, ... ,0.999], [0.222, 0.223, ..., 0.999])
Can someone tell me how to parse the text file as tuple in Julia?
I have saved some data in Julia without any thought for formatting it. The saved file look something like the following;
([0.123, 0.124, ... ,0.999], [0.222, 0.223, ..., 0.999])
Can someone tell me how to parse the text file as tuple in Julia?
It’s bad practice in general, but for a once-off to fix a mistake you could do:
str = readchomp(filename)
t = eval(Meta.parse(str))
I’d recommend just using JLD2.jl.
You can just do:
julia> data = rand(10,10);
julia> JLD2.jldsave("data.jld2"; data=data)
julia> JLD2.load("data.jld2")
Dict{String, Any} with 1 entry:
"data" => [0.636269 0.0650003 … 0.758512 0.482105; 0.385604 0.769785 … 0.3141…
julia> data2 = JLD2.load("data.jld2")["data"]; data == data2
true