Reply-to: gamsworld@googlegroups.com
Hi,
In the very last release 24.4.6 we have included an experimental feature to skip rows and columns when reading data from Excel that should help you:
$onecho > task.txt
dset=i rng=Sheet1!a2 rdim=1
par=b1 rng=Sheet1!a2 rdim=1
par=b2 rng=Sheet1!a2 rdim=1 IgnoreColumns=B
par=b3 rng=Sheet1!a2 rdim=1 IgnoreColumns=B,C
$offecho
$call gdxxrw.exe Book1.xlsx @task.txt
$if errorlevel 1 $abort problems with gdxxrw
Another safe alternative is to read the data as a two dimensional parameter and then in GAMS do the assignment to several one dimensional parameters:
$onecho > task.txt
dset=i rng=Sheet1!a2 rdim=1
par=bAll rng=Sheet1!a1 rdim=1 cdim=1
$offecho
$call gdxxrw.exe Book1.xlsx @task.txt
$if errorlevel 1 $abort problems with gdxxrw
set i,j /b1,b2,b3/;
parameter bAll(i,j), b1(i), b2(i), b3(i);
$gdxin Book1.gdx
$load i
$loadDC bAll
b1(i) = bAll(i,‘b1’);
b2(i) = bAll(i,‘b2’);
b3(i) = bAll(i,‘b3’);
display b1,b2,b3;
The listing file contains the following display results:
---- 19 PARAMETER b1
a1 1.000, a2 3.000, a3 5.000, a4 7.000, a5 9.000
---- 19 PARAMETER b2
a1 4.000, a2 6.000, a3 8.000, a4 10.000, a5 12.000
---- 19 PARAMETER b3
a1 3.000, a2 7.000, a3 11.000, a4 15.000, a5 19.000
Hope this helps,
Michael Bussieck - GamsWorld Coordinator
On Saturday, July 18, 2015 at 3:14:32 PM UTC-4, Partha Das wrote:
Hi members,
I am new to GAMS and having little problem in calling parameters from excel using gdxxrw.
Suppose I have following table in excel
b1 b2 b3
a1 1 4 3
a2 3 6 7
a3 5 8 11
a4 7 10 15
a5 9 12 19
I am able to declare a1…a5 are member of the set i. I want to declare b1…b3 as parameters e.g. b1(i). I can declare parameter b1 very easily using following code. But having difficulty with b2 & b3. Is it true that the parameter values have to be in adjacent column to the set members in excel sheet?
$onecho > task.txt
dset=i rng=Sheet2!a2 rdim=1
par=b1 rng=Sheet2!a2 rdim=1
$offecho
$call gdxxrw.exe data1.xlsx @task.txt
I have consulted gdxutils.pdf (specially example 14) and also previous posts in the group but couldn’t find an relevant example. May be missing something. Can anybody help?
On Wednesday, 8 September 2010 18:23:00 UTC+5:30, TuyiRich wrote:
Thanks Michael,
I eventually managed it using the GDXXRW.EXE.
Richard.
On 8 September 2010 14:49, Gamsworld Admin wrote:
Hi, wy don’t you post the complete log file and the Excel spreatsheet.
With that we might be able to reproduce the problem or help otherwise.
There is an upload section for this group.
Michael Bussieck - GAMSWorld Coordinator
On Aug 22, 4:37 pm, trgzrich wrote:
Hi members,
I am trying to call some parameters from Excel (attached below) to
GAMS. The Biomass, Geothermal…Large_H are indexed as k, and are
in column k of the worksheet, starting with A2. The parameters l want
to call are; invc,icap,Capftr1, Capftr2,gmcost,gfcost, and glost. They
are in columns B1, C1, D1, …, H1, respectively. The last row of the
worksheet is 9
I am using the following GAMS code (copied below) to call the “invc”
parameter, but its reporting an error that “Input file not found”.
The GAMS file and the GAMSOOdata.xls are in the same folder “C:
\Documents and Settings\Administrator\My Documents\gamsdir\projdir”
Where could l be going wrongs? I need your help. Thanks.
$CALL GDXXRW GAMSOOdata.xls par=invc rng=A1:B9
Parameter invc(k);
$GDXIN GAMSOOdata.gdx
$LOAD invc
$GDXIN
invc icap Capftr1 Capftr2 gmcost gfcost glost
Biomass 2.50 0 0.7 0.5 0.019 0.023 0.08
Geothermal 3.01 0 0.8 0.6 0.023 0.037 0.03
Wind 2.90 0 0.6 0.4 0.016 0.02 0.07
Solar 3.60 0 0.5 0.3 0.012 0.021 0.02
Thermal 4.00 200 0.8 0.6 0.026 0.035 0.09
Bagasse 2.85 12 0.7 0.5 0.014 0.029 0.04
Small_H 2.70 15 0.8 0.6 0.019 0.025 0.07
Large_H 2.10 300 0.9 0.7 0.023 0.031 0.09
TUYIRAGIZE RICHARD
Institute of Statistics & Applied Economics,
Makerere University,
P.O.Box 7062,
Kampala-Uganda.
Tel(O): +256-414-541558
Tel(M): +256-775-115365(UG)
Tel(M): +27 -734-502185(SA)
Fax: +256-414-530756
Email: tuyi…@isae.mak.ac.ug
trgz...@gmail.com
trgz...@yahoo.com
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.