I'm running a simulation with parallel, and I want the results from each parameter set exported to a file whenever it's done (because the parameter space is huge and my computer doesn't have enough memory to keep all the results). This is the code I tried:
output = OpenWrite["file.txt", PageWidth -> Infinity];
WriteString[output, "certain text"];
WriteString[output, "\n"];
ParallelDo[
myarray=myfunction[i,j,k];
Export[output, myarray // N, "CSV"];
WriteString[output, "\n"],
{i,5},{j,4},{k,3}
]
Unfortunately I keep getting this error message which I don't understand:
CharacterEncoding is not a known option for OutputStream[file.txt,82].
The problem does not occur when I use Do instead of ParallelDo. So I'm guessing it's got something to do with parallelization. What am I missing here?
--------edit----------
Apparently when I use PutAppend I don't get any error message, but I can't figure out how to remove the quotation marks and the line brakes in the middle of the data.
Method -> "CoarsestGrained"– Peter Roberge Apr 12 '16 at 21:32