How do you get a Matrix back from a file?

It’s likely the wrong approach, it only stores the values, not dimensions here 20, 20, so it might as well be a vector of 400. Only do this in very few cases, where you know the dimensions of the data to be static (in case you want to write more to the file). What you likely want is some kind of serialization system, there are many, but this one works, and I think it may be the best one:

Well neither is it straightforward (if you want to store more than one string in a file), because I checked and it stores the String exactly, in my test “Palli”, my name as 5 bytes, not even a trailing \0 or length, so write, and its docs are rather useless and misleading. I feel it’s missing a note, stating most should rather use JLD2.jl (and some software, likely it, might use write indirectly for you).

1 Like