Saving result on MAC

Problems with syntax of GAMS
Post Reply
martinagherardi
User
User
Posts: 13
Joined: 2 years ago

Saving result on MAC

Post by martinagherardi »

Hi,

How can I write my GAMS result using a mac?

For the import of the data, I create GDX files with Windows but for saving the results I don't know how to do it.
The command
execute 'gdxxrw.exe result.gdx o=result.xlsx par=result'
doesn't work.

Thank you in advance
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Saving result on MAC

Post by bussieck »

Just do this opposite. Bring the result.gdx over to your Windows machine and run gdxxrw to create results.xlsx from your results.gdx.

-Michael
martinagherardi
User
User
Posts: 13
Joined: 2 years ago

Re: Saving result on MAC

Post by martinagherardi »

Many thanks Bussieck to reply,

there is an alternative for working only with mac?
I saw that it is possible to work with CSV but I did not find any example for exporting results
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Saving result on MAC

Post by bussieck »

The put file facility (https://www.gams.com/latest/docs/UG_Put.html) gives you access to creating your own ASCII files, including CSV file. You can also use gdxdump (https://www.gams.com/latest/docs/T_GDXD ... ING_TO_CSV). If you search the GAMS documentation (yes, there is a search!) for CSV you will get many good hits, like https://www.gams.com/38/docs/UG_DataExchange_ASCII.html.

-Michael
martinagherardi
User
User
Posts: 13
Joined: 2 years ago

Re: Saving result on MAC

Post by martinagherardi »

Hi Michael

I am still having problems with csv, please bear with me...
I followed a lot of examples but I can’t import a multidimension parameter (3 dim) defined in the following CSV
FUEL_PRICE-Stoc 2.csv
(880 Bytes) Downloaded 112 times
The code is the following

Table fuel_price(year,fuel,scen);
$call csv2gdx "/Users/martinagherardi/Desktop/Visiting/2022-04-12 comparison/FUEL_PRICE-Stoc 2.csv" output="/Users/martinagherardi/Desktop/Visiting/2022-04-12 comparison/FUEL_PRICE-Stoc 2.gdx" id=fuel_price index=1,2 values=2..lastCol useHeader=y valueDim=y

$GDXIN FUEL_PRICE-Stoc 2.gdx
$onUNDF
$LOAD fuel_price
$GDXIN

The GDX file is created but the dimensions are wrong ….
Could you help me please ?
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Saving result on MAC

Post by bussieck »

CSV files usually have a single header file (at least csv2gdx only understands those CSV files). You need to reshuffle your file like this:

Code: Select all

fuel,scen,2017
Gas1,Scen1,9.79
Gas1,Scen2,9.79
Gas1,Scen3,9.89
...
The following csv2gdx call "csv2gdx x.csv output=x.gdx id=fuel_price index=1..2 values=3..lastCol useHeader=y valueDim=y" should work properly. You need to declare your parameter fuel_price with a different domain set order: fuel_price(fuel,scen,year).

-Michael
martinagherardi
User
User
Posts: 13
Joined: 2 years ago

Re: Saving result on MAC

Post by martinagherardi »

Hi Michael,
many thanks for the reply.

I saw that in the reshuffle you didn't write year. How can I deal with values for multiple years? so for example if the set of years contains 2017 and 2018
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Saving result on MAC

Post by bussieck »

Just add them as columns:

Code: Select all

fuel,scen,2017,2018
Gas1,Scen1,9.79,10.01
Gas1,Scen2,9.79,10.02
Gas1,Scen3,9.89,10.03
...
-Michael
Post Reply