Page 1 of 1

Data Import from Excel

Posted: Tue Mar 29, 2022 2:55 pm
by TheBebbo
Hi guys!
I want to import data from excel to GAMS. So I tried to define a GTX data but it doesn't work out and I can't find the problem.


Set
t "time" /1*5/;

Parameter C(t);

$call gdxxrw.exe example.xlsx par=t rng=tabelle2!A1:A5 Rdim=1

$GDXIN example.gdx
$LOAD C
$GDXIN
Display C;



example.xlsx is the name of my excel data
tabelle2 is the name of my excel sheet
A1:A5 are the excel cells with my values.


The error " CALL failed" appears.

Is there anyone who knows my fault?
I´m thankful for every advice.

Greetings TheBebbo

Re: Data Import from Excel

Posted: Tue Mar 29, 2022 3:10 pm
by Fred
Hi,

GDXXRW is a Windows only tool. Are you eventually trying to use it under a different OS?

Fred

Re: Data Import from Excel

Posted: Tue Mar 29, 2022 3:14 pm
by TheBebbo
Hi Fred,
thanks for your reply! That's gonna be the problem. I´m using MacOS. Is there an equivalent command for MacOS?

TheBebbo

Re: Data Import from Excel

Posted: Tue Mar 29, 2022 4:08 pm
by Fred
Nope. Even though Excel is available on the Mac, it does not support the MS Office OLE interface required by gdxxrw which is why gdxxrw is not available for mac/linux (see platform/tool availability matrix in our docs . So you either run gdxxrw on Windows and bring the GDX over to the Mac or export the required sheets to CSV files and read these into GAMS (see https://www.gams.com/latest/docs/UG_Dat ... ASCII.html or https://www.gams.com/latest/docs/T_CSV2GDX.html).

The upcoming GAMS 39 (beta) will come with the new GAMS Connect framework which allows to integrate data from various data sources (among others Excel). But but this will still take a few weeks.

Fred

Re: Data Import from Excel

Posted: Tue Apr 05, 2022 8:22 pm
by TheBebbo
With your help I could create the GDX file on windows and sent the cdx file to my MAC. Now I need to open the gdx in GAMS.


$GDXIN Input_data.gdx
$LOAD X, Y , z.
$GDXIN

That's what I tried but it didn't work out. Maybe you could help me one more time.

Thank you in advance! :)

Re: Data Import from Excel

Posted: Wed Apr 06, 2022 7:44 am
by Fred
Please share an example that allows other forum users to do what you are doing as suggested in the forum rules.

Fred

Re: Data Import from Excel

Posted: Wed Apr 06, 2022 8:47 am
by TheBebbo
Here my example:

Set
t Time /1*50/


Parameters
X(t) Costs for X
Y(t) Costs for Y
Z(t) Costs for Y;

$GDXIN X-Y-Z.gdx
$LOAD X, Y , Z
$GDXIN


In the gdx file are the 50 values for x y z. But if I wanna run the code the error "Unable to open gdx file for $GDXIN" appears.

Re: Data Import from Excel

Posted: Thu Apr 07, 2022 7:51 am
by Fred
You have the GDX file in your working directory, do you? Please share the GDX file as well. Otherwise one can still not run your example. Sharing a full log that shows some context around the error would also be good.

Fred

Re: Data Import from Excel

Posted: Wed Apr 20, 2022 12:56 pm
by TheBebbo
Thank you Fred. I found the problem. The GDX File had more than only the 50 values and I couldn't use all values because of my demo license.