Right now my code is something like
Put[
Table[
*some calculations*
{SparseArray[matrix], coordinates},
{i, 1, numIterations}
],
destinationFile
]
As far as I can tell, this requires that the Table
finish evaluating in full, which ends up storing a list of numIterations
copies of my matrices and coordinates, before it can write those to a file en mass. The issue with this is that I'm working on a research system with very tight memory usage restrictions. This tends to run over the memory cap before it finishes executing. What I would like to be able to do is serialize that output (replacing Table
by Do
) such that it never has to store more than one copy of the matrix and the coordinates in memory.
Using PutAppend
doesn't work because I later need to be able to read this back in as a list in another notebook, and PutAppend
places newlines after everything so I can't actually re-create the output format from Put
manually. Are there ways to do this that aren't too horrible?