JLD.jl
JLD.jl copied to clipboard
save("file.jld", "foo", foo) overwrites contents of file
It seems like the file is opened in "w" mode and thereby other variables saved in the same file are lost. Is there any reason why this is preferable to appending data to a file? (I notice that the FileIO.jl package has a similar setting)
I feel that appending would be least surprising for the user.
Yep, same opinion. Can it be possible to only write or modify one field on the Dictionary of the file? Maybe using jldopen("somefile.jld")
?
Yeah, this tripped me up for a couple hours. In fact, is there any way to append to an existing JLD file at all (even if it's not the default behavior in "w" mode)?
"r+"
One issue is that the save
function is generic and operates not only on JLD files, which support appending data, but also on many other file types that don't support append, so making append mode the default would not lead to consistent generic behavior.
I see. In such a case, could the method(s) be more appropriately named save!()
? This would make explicit the potential for overwriting the data.