Loading data from Excel Sheet into GAMS

Hello Everyone,

I want to load data from excel sheet into GAMS, each excel sheet has one column and 8760 rows (where each row has a values), and I am using the below code,

Parameter PV_Available(k);
$call gdxxrw “C:\Users\omarr\OneDrive\Desktop\GAMS\Model Development\Fourth Draft (First Run)\Data\PV_Available.xlsx” par=PV_Available rng=Sheet1!A1:A8760 rdim=1 output=“PV_Available.gdx”
$gdxin PV_Available.gdx
$load PV_Available
$gdxin

Parameter Wind_Available(k);
$call gdxxrw “C:\Users\omarr\OneDrive\Desktop\GAMS\Model Development\Fourth Draft (First Run)\Data\Wind_Available.xlsx” par=Wind_Available rng=Sheet1!A1:A8760 rdim=1 output=“Wind_Available.gdx”
$gdxin Wind_Available.gdx
$load Wind_Available
$gdxin

The code is running without errors, but the created gdx files do not have the data avaialble in the excel sheets,

Could someone please help me identifying where is the error?
Kind regards,
Omar

Sure, if you provide the Excel files to see what’s going on.

-Michael

Hi Michael,

Thank you for your reply!

I have attached the excel sheets and the created gdx files,

I hope you will be able to access them,

kind regards,
Omar
Wind_Available.gdx (86.3 KB)
PV_Available.gdx (48.5 KB)
PV_Available.xlsx (108 KB)
Wind_Available.xlsx (136 KB)

Please read the documentation of gdxxrw at https://www.gams.com/latest/docs/T_GDXXRW.html. All parameters are read with the index k and the value of the parameter in the neighboring cell. Your sheets don’t mention the index (k) at all. You did not provide the elements of set k, but here I am assuming the set k consists of k1,k2,k3,…,k8760 then your Excel data should look as follows:
Screenshot 2023-06-22 131125.png
and you need to adjust your rng parameter to rng=Sheet1:A1:B8760. Then the GDX file will have the expected data.

-Michael

Thank you! It works and I have used the documentation to learn how to show the zero values by disabling the squeeze option.
kind regards,
Omar