Although I have been using Julia for over a year now, I still have problems with basic things, so I consider myself to be a ‘newbie’, so please be gentle.
I would like a simple way for me (and my students) to be able to save a few variables to the same file, and read them in again.
There have been many suggestions on here, and this seems to evolve all the time, but I can’t seem to find a simple answer.
Suppose there are arrays A1 and A2
I would like something like
write(filename, A1, A2)
Or even to be able to read and write a dictionary of variables
I find it surprising that after all the time and work which has been devoted
to the Julia project, there is no clear and simple solution to this (or at least
one I could find).
PS. MAT seemed to do what I wanted, but the files are huge (even with compression) and anyway, it doesn’t seem to be supported any more (or at least it doesn’t work for me).
What is an MWE? If in my example above, A2 were a DataFrame, for example? That would be an example with as much generality as I would envision. Pickle can handle DataFrames in python. Maybe I am thinking about a Julia equivalent of pickle.
(though I know Julia is not python, some concepts are obviously ‘inspired’ by pythonian ones)
I concur with the suggestion to use serialize for short-term storage - basically, when you are in principle OK with the file becoming unreadable after updating Julia. To store data in the long-term it’s better to write as a “common” format, not a julia-specific one: csv/JSON/BSON/database/parquet/hdf/… Note that this is also true when using other languages, e.g. python: I myself experienced several times that pickle couldn’t read the data back when some packages got updated.