Excel to gams

Problems with syntax of GAMS
Post Reply
mahyar
User
User
Posts: 2
Joined: 7 months ago

Excel to gams

Post by mahyar » 6 months ago

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 30 times
abcd.gms
(191 Bytes) Downloaded 25 times

User avatar
Renger
Posts: 127
Joined: 1 year ago

Re: Excel to gams

Post by Renger » 6 months ago

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

Job
User
User
Posts: 5
Joined: 9 months ago

Re: Excel to gams

Post by Job » 6 months ago

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