This is in 0.6-rc1 (and earlier):
julia> writecsv("/tmp/comp.csv",[1+im])
julia> readcsv("/tmp/comp.csv")
1脳1 Array{Any,2}:
"1 + 1im"
I would expect it to return an Array{Complex{Int},2}.
PS A quick work around is eval.(parse.(readcsv("/tmp/comp.csv")))
Same for {read, write}dlm.
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.1-pre.0 (2017-06-19 13:06 UTC)
_/ |\__'_|_|_|\__'_| | Commit dcf39a1 (64 days old release-0.6)
|__/ | x86_64-apple-darwin15.6.0
julia> writedlm("tmp", randn(2, 2) + randn(2, 2)*im)
shell> cat tmp
0.7743929262024812 - 0.3434835979330062im 0.33958454399005045 + 0.28680652862126105im
0.6928954470238671 + 1.597743784536779im -0.04481314483176969 + 0.48528071828620334im
julia> readdlm("tmp")
2脳6 Array{Any,2}:
0.774393 "-" "0.3434835979330062im" 0.339585 "+" "0.28680652862126105im"
0.692895 "+" "1.597743784536779im" -0.0448131 "+" "0.48528071828620334im"
readdlm is no longer in Base.
It's in the stdlib which exists in this repo though?
Yeah, until we move things into separate repos, this is still the right place for these issues.
Fair enough. In this case, it isn't even clear if readdlm can or should deal with complex numbers given all the ways one could use whitespace. A CSV file could perhaps be easier to work with.
@ViralBShah IMO, if Base exposes the capability of writing a complex array to a file using 'writedlm', it should also expose some way to read it.
That is fair enough. I would argue that writedlm should not accept this. CSV.jl or JLD are better unambiguous ways to do this.
readdlm support for Complex{T} (actually requiring less code in DelimitedFiles.jl), though you have to explicitly specify the desired complex type (since the default in readdlm is Float64).
Most helpful comment
@ViralBShah IMO, if Base exposes the capability of writing a complex array to a file using 'writedlm', it should also expose some way to read it.