Is there an easy way to write a composite and then read it back in?

Is it possible to write a vector of composites to a file in such a way that it can be read back in, somewhat similar to the following?

ILGPennTreebank=Vector{ILGPennTreebankRow}()
##push elements onto above vector, then
  open(savebin_ILGPT_Dataset, "tmp.bin","w")
  open(readbin_ILGPT_Dataset, "tmp.bin")

function savebin_ILGPT_Dataset(archiveDS::IOStream)
  println("Archiving")
  write(archiveDS,ILGPennTreebank)
end

function readbin_ILGPT_Dataset(archiveDS::IOStream)
  println("Reading archive")
  tmp=read(archiveDS,Vector{ILGPennTreebankRow})
  println(tmp)
end

See package JLD
GitHub - JuliaIO/JLD.jl: Saving and loading julia variables while preserving native types

1 Like