Hello,
We have a model which needs to read in hundreds of GDX files. However, to limit the overhead, we try to limit the number of files actually read in through only ‘sending’ it the files it needs. See the following statement:
$if exist "<filename.csv>" $call csv2gdx "<filename.csv>" output="<filename.gdx>" id=Par_name ...
$if exist '<filename.csv>' Execute_load '<filename.gdx>' Par_name =Par_name ;
Here, we only send a handful of CSV’s instead of the hundreds it could possibly ingest. However, as we expand the model, we are finding this is intractable to do for every file. We are trying to take advantage of file naming to make this process easier. Thus we are transitioning to using put_utilities to read the files in a loop. We are able to successfully create the GDX files in a loop with the following code:
loop(fueltype,
put_utility 'shell' / 'if exist ".\FuelLimit_' fueltype.tl:0 '_N1.csv" csv2gdx ".\FuelLimit_' fueltype.tl:0 '_N1.csv" output=".\FuelLimit_' fueltype.tl:0 '_N1.gdx" id=FuelLimitIn index=1,2 values=3..lastCol useHeader=y'
);
loop(fueltype,
put_utilities dummyFile 'gdxin' / '.\FuelLimit_' fueltype.tl:0 '_N1.gdx'
execute_load dummyPar=FuelLimitIn;
par_dgfuellimit_hourly(fueltype)= dummyPar;
);
However, this code will fail if the GDX file does not exist. We have tried, but it seems there is no way to embed an ‘if exists’ in the last put_utilities sequence. Do you have any suggested workarounds here?