Hi!
My question is very simple, I have a one dimensional complex array, for example:
A = [1.0 + 0.1im, 2.0 + 1.0im, 1.5 + 0.5im];
typeof(A)
Array{Complex{Float64},1}
I want to write this array in a .txt file with DelimitedFiles
, so I type the following comand:
open("MyComplexArray.txt", "w") do io
writedlm(io, A)
end;
Finally, I want to read the data from MyComplexArray.txt
by running:
readArray = readdlm("MyComplexArray.txt", '\t', Complex{Float64}, '\n')
3×1 Array{Complex{Float64},2}:
1.0 + 0.1im
2.0 + 1.0im
1.5 + 0.5im
typeof(readArray)
Array{Complex{Float64},2}
As you can see, this returned a two dimensional complex array with dimension 3x1
, and I want a unidimensional array, like the original array A.
I already tried the command readdlm with no delimiters, but gives me an error:
readArray = readdlm("MyComplexArray.txt", Complex{Float64})
ERROR: at row 1, column 1 : ErrorException("file entry \"1.0\" cannot be converted to Complex{Float64}")
Does anyone knows how to avoid this situation? With other data types, such integers or floats this doesn’t happen!
Cheers,
Tiago