6
$\begingroup$

tldr: is there a way to load all files following a structure/append to DumpSave file

i would like to run a script following the structure:

Get['lib.wl']
data = initializeDataSet[] 
DumpSave['save0', data]

result1 = compute1[]
DumpSave['save1', result1]
Clear[result1]

.
.
.

resultn = computen[]
DumpSave['saven', resultn]
Clear[resultn]

is there a good way to load all saves without going >>save0 to >>saven. Or is this manual work needed? A Get[name] where name allows for joker would suffice, but I don't think it exists. Putting them into a separate folder seems sensible.

Just saving at the end doesn't seem viable/safe to me in case of an unexpected early exit.

Edit: just discovered FileNames[] is a thing. the solution would be like:

names = FileNames[pattern,{directory}]
Do[Get[fileName], {fileName, names}]
$\endgroup$
  • $\begingroup$ please add you solution as an answer rather than part of the question? $\endgroup$ – chris Aug 30 '18 at 8:45
7
$\begingroup$

You can use Get/@ FileNames["save*"].

$\endgroup$
5
$\begingroup$
Get /@ StringTemplate["save``"] /@ Range[1, 5]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.