put_utilities does not work with several print control options

Problems with syntax of GAMS
Post Reply
pecenak21
User
User
Posts: 3
Joined: 9 months ago

put_utilities does not work with several print control options

Post by pecenak21 » 9 months ago

Hi,

I am trying to run my code in a loop and output a .csv, where each CSV has a different name (i.e. year1.csv, year2.csv ...). However, I am noticing that any of the formatted outputs (which I need for the next step of my code) do not work with put_utilities.

Specifically, the lines

put_utility 'ren' / 'test.csv' ;
contingencies.pc = 5;

clash with one another. I was wondering if this was a bug that could be fixed, or if someone could suggest a workaround. Such as another way to dynamically save each loop in a different .csv (or different sheet on an excel file).

Code: Select all

file contingencies /file.csv/;

set yearSim /1*2/;
loop(yearSim,

put contingencies;

put_utility 'ren' / 'test.csv' ;
contingencies.pc = 5;

put 'month', 'daytype', 'hour';
putclose contingencies ;

);

Lutz
User
User
Posts: 26
Joined: 2 years ago

Re: put_utilities does not work with several print control options

Post by Lutz » 9 months ago

Hi,

This is clearly a bug in the system (it happens with all settings for .pc which add quotes automatically). As a workaround you could set .pc=2 before the rename and set it back to 5 afterwards (note that I also used yearSim.tl in the rename command to actually generate different files, before you had just one file name):

Code: Select all

file contingencies /file.csv/;

set yearSim /1*2/;
loop(yearSim,

put contingencies;

contingencies.pc = 2;
put_utility 'ren' / 'test' yearSim.tl:0 '.csv' ;
contingencies.pc = 5;

put 'month', 'daytype', 'hour';
putclose contingencies ;

);
Hope that helps,
Lutz

pecenak21
User
User
Posts: 3
Joined: 9 months ago

Re: put_utilities does not work with several print control options

Post by pecenak21 » 9 months ago

Thanks for the extremely fast reply. This is such a great (And simple!) fix. It solves my problem completely.

With much appreciation,
Zack

Post Reply