Excel to gams

Problems with syntax of GAMS
Post Reply
mahyar
User
User
Posts: 2
Joined: 6 years ago

Excel to gams

Post by mahyar »

Hi Everyone.
I have a problem.
I want to import data from excel to gams.i has written the following code

$call GDXXRW.exe indata1.xlsx trace=3 par=a rng=Interval!a1 rdim=1 cdim=1
$load a
display a;

but no value has been assigned.
I attached my files.
Attachments
indata1.xlsx
(8.44 KiB) Downloaded 306 times
abcd.gms
(191 Bytes) Downloaded 274 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Excel to gams

Post by Renger »

Hi Mayhar

You use rdim=1 cdim=1 which implies a dimension of 2, but you define a as a(i), which has a dimension of 1 (i). So either you keep a(i) and write (note that I start at a2):
parameter a(i) beginning of interval for jobs
$call 'GDXXRW.exe indata1.xlsx par=a rng=Interval!a2 rdim=1 trace = 3'
$gdxin 'indata1.gdx';
$load a
display a
Or you make the parameter a two-dimensional, e.g. a(i,*) and you write
parameter a(i,*) beginning of interval for jobs
$call 'GDXXRW.exe indata1.xlsx par=a rng=Interval!a1 rdim=1 cdim=1 trace = 3'

$gdxin 'indata1.gdx';
$load a
display a
Hope, this helps
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Job
User
User
Posts: 6
Joined: 6 years ago

Re: Excel to gams

Post by Job »

This is my codes to transfer data from excel to GAMS. The code works well but the data display is "TRUE" for all cells and when the variables are called the data turns to "1.000" all. Some of the data are actually "1.000", but not all. Please what can I do. I need urgent help to continue with my project.

$CALL GDXXRW.EXE Nigeria_data.xlsx par=tyyz rng=sheet2!a1..k10
$GDXIN Nigeria_data.gdx
$LOADDC tyyz
$GDXIN
;
Post Reply