Data Import from Excel

questions about GAMS' tools
Post Reply
TheBebbo
User
User
Posts: 16
Joined: 8 months ago

Data Import from Excel

Post by TheBebbo » 8 months ago

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

Fred
Posts: 323
Joined: 6 years ago

Re: Data Import from Excel

Post by Fred » 8 months ago

Hi,

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

Fred

TheBebbo
User
User
Posts: 16
Joined: 8 months ago

Re: Data Import from Excel

Post by TheBebbo » 8 months ago

Hi Fred,
thanks for your reply! That's gonna be the problem. I´m using MacOS. Is there an equivalent command for MacOS?

TheBebbo

Fred
Posts: 323
Joined: 6 years ago

Re: Data Import from Excel

Post by Fred » 8 months ago

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

TheBebbo
User
User
Posts: 16
Joined: 8 months ago

Re: Data Import from Excel

Post by TheBebbo » 8 months ago

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! :)

Fred
Posts: 323
Joined: 6 years ago

Re: Data Import from Excel

Post by Fred » 8 months ago

Please share an example that allows other forum users to do what you are doing as suggested in the forum rules.

Fred

TheBebbo
User
User
Posts: 16
Joined: 8 months ago

Re: Data Import from Excel

Post by TheBebbo » 8 months ago

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.

Fred
Posts: 323
Joined: 6 years ago

Re: Data Import from Excel

Post by Fred » 8 months ago

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

TheBebbo
User
User
Posts: 16
Joined: 8 months ago

Re: Data Import from Excel

Post by TheBebbo » 7 months ago

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.

Post Reply