Data exchange from excel to gams (on macOS)

questions about GAMS' tools
Post Reply
marco
User
User
Posts: 4
Joined: 5 months ago

Data exchange from excel to gams (on macOS)

Post by marco » 5 months ago

Hi everyone
I would like to enter the data for parameters from an excel-file with several sheets. I created a model which seems to work with data entered in the simplest way possible but as I want to extend the model with larger data sets I need another method to integrate/include the data.

As I am working on a macOS computer i cannot use the gdxxrw method (as far as I understand it). I tried the following 3 other methods from the tutorial and documentary:

- Data Exchange with Text Files (https://www.gams.com/latest/docs/UG_Dat ... ASCII.html)
- Data Exchange with CSV2GDX (https://www.gams.com/latest/docs/T_CSV2GDX.html)
- Data Exchange with GAMS Connect (https://www.gams.com/latest/docs/UG_GAMSCONNECT.html)

Unfortunately these methods do not work on my model / computer. What method would you suggest for integrating greater data sets from excel to GAMS (on a mac computer)? Is any method advantageous compared to another one?

And sorry for the naive choice of words. I'm a newbie in GAMS and in programming in general.

I would greatly appreciate any help or hint from you. Thanks a lot in advance.

Marco
Strommarkt mit loop + Data CSV2GDX.zip
With csv2gdx data exchange (does not work)
(24.76 KiB) Downloaded 119 times
Strommarkt mit loop + Data Connect.zip
With connect data exchange (does not work)
(24.79 KiB) Downloaded 121 times
Strommarkt mit loop.zip
No data exchange (simple but works)
(17.31 KiB) Downloaded 115 times

aileen
User
User
Posts: 133
Joined: 2 years ago

Re: Data exchange from excel to gams (on macOS)

Post by aileen » 5 months ago

Hi Marco,

GAMS Connect is a new platform independent tool set to read data from a range of external sources (including Excel), transform it, and make it available to GAMS models. This will be the future for data connectivity in GAMS. We already announced the retirement of a couple of older data tools and will offer proper replacements in Connect. To be able to use Connect you will need to update to GAMS 39.
I attached your example with some minor modifications to get it running. The added < characters in the parameter declaration will implicitly define the sets i, j and h. I also needed to modify the Excel file a bit (see attached) since the PandasExcelReader expects artificial indices for rowDimension=0 and/or columnDimension=0 (see https://www.gams.com/latest/docs/UG_GAM ... DERCONCEPT).

Best,
Aileen
Strommarkt mit loop + Data Connect.gms
(7.02 KiB) Downloaded 129 times
indata.xlsx
(17.41 KiB) Downloaded 123 times

marco
User
User
Posts: 4
Joined: 5 months ago

Re: Data exchange from excel to gams (on macOS)

Post by marco » 5 months ago

Hi Aileen

Thank you very much for the explanations and for the modifications to the model and to the excel file. I'm so happy about your help. It would have taken me ages to find all that information and solve these errors.

Thanks again and best regards
Marco

T_k
User
User
Posts: 4
Joined: 3 weeks ago

Re: Data exchange from excel to gams (on macOS)

Post by T_k » 2 weeks ago

Hi Aileen, thanks for the explanation. I am wondering how we could be able to write data from GAMS to excel. I would be grateful if you provide me any resource or a simple example code.

Troy23
User
User
Posts: 1
Joined: 2 weeks ago

Re: Data exchange from excel to gams (on macOS)

Post by Troy23 » 2 weeks ago

Hello,

I would also be very interested in these resources or simple codes as @T_k said. It will be a great help for me.
My website here

User avatar
bussieck
Moderator
Moderator
Posts: 859
Joined: 6 years ago

Re: Data exchange from excel to gams (on macOS)

Post by bussieck » 2 weeks ago

The GAMS Connect documentation has examples: https://www.gams.com/latest/docs/UG_GAM ... _CONNECT03

-Michael

Post Reply