How to optymaly to save strings in JLD ? What wrong?


i have long vecotr od srings, dane[:,5]
12245198 -element Array{Any,1}:

saved by

is only ±33 000 KB

but saved by
`file = jldopen(“file.jld”,“w”)
file = jldopen(“file.jld”,“r+”)

@time write(file,“user”,string.(dane[:,5]))

created file over 40 000 000 KB !!! What wrong ? How to optymaly this vector to save in JLD ? …as string.


Try JLD2? Also please quote code with ` and blocks of code with ```.


Also, if each element of that array

  1. contains only ASCII characters,
  2. has uniform length, or variable length that can be bounded by a small number,

then Matrix{UInt8} is also a viable choice.

If the strings repeat a lot, you could collect them and index into it. See for example


Yes, JLD2 make to lage file also!


What happens if you convert the array to actually be of type Vector{String} instead of Vector{Any}?


Thanks, convert(Array{String},a) with JLD working better!

BUT, if i Have vector “a” {Any} like below. In this case is npossible to make CONVERT(…

If i am using string.(a) the saved data are huge:/
What to do ?

julia> a
2-element Array{Any,1}:

julia> string.(a)
2-element Array{String,1}:

julia> convert(Array{String},a)
ERROR: MethodError: Cannot convert an object of type Int64 to an object of type String
This may have arisen from a call to the constructor String(…),
since type constructors fall back to convert methods.
in copy!(::Base.LinearFast, ::Array{String,1}, ::Base.LinearFast, ::Array{Any,1}) at .\abstractarray.jl:559
in convert(::Type{Array{String,N}}, ::Array{Any,1}) at .\array.jl:235


I have !


string.(a) doesn’t modify a, it returns a new array.