Saving result on MAC

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

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

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

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_GDXDUMP.html#GDXDUMP_EXAMPLES_WRITING_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

CO2_PRICE-Stoc.prova.csv (289 Bytes)
Hi Michael

I am still having problems with csv, please bear with me…
I followed your example https://newforum.gams.com/t/several-error-messages-when-reading-csv-file/2323/1
and I also checked the GAMS documentation

http://ikucukkoc.baun.edu.tr/lectures/EMM3208/gams_users_guide.pdf

I’m trying to import this csv
CO2_PRICE-Stoc.prova.csv (289 Bytes)
D8BE1210-3FD3-432E-BEB7-ABE7DFD96178.png
with the following code

Parameter co2_price(year,scen) /
$ondelim
$include “/Users/martinagherardi/Desktop/Visiting/2022-04-12 comparison/CO2_PRICE-Stoc.prova.csv”
$offdelim
/;

but when I import my .csv file, I obtain the “domain violation” error.
78A8628D-8F82-46D8-B599-CD232B0EDA1F.png
C3E78449-948E-49C3-8AFC-73E19462594B.png

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)
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 ?

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

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

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

Just add them as columns:

fuel,scen,2017,2018
Gas1,Scen1,9.79,10.01
Gas1,Scen2,9.79,10.02
Gas1,Scen3,9.89,10.03
...

-Michael