Page 1 of 1

read multidim sets from Excel

Posted: Sat May 11, 2019 5:18 pm
by Flo
Hi all,
would be great to get your help. I have three sets and want to import them from Excel without assigning values. I found ways to import n and u, but this multidimensional nu seems problematic.

ExcelTab (columns A and B)
n1; u1

n Node
u Unit
nu NodeUnit

Perfect would be something like:
$Onecho > task.txt
Set=nu rng=ExcelTab!A1 rdim=1
$call GDXXRW ... @task.txt

At the end, I need the set nu(n,u)

Re: read multidim sets from Excel

Posted: Mon May 13, 2019 2:25 pm
by Fred

To read a 2 dimensional set in the described format from Excel you need rdim=2 cdim=0 (see

Assuming your data is stored in x.xlsx, the following example should do the trick (it also shows how to get sets n and u out of nu if you don't want to read them separately).

Code: Select all

set n,u,nu(n,u);
$call gdxxrw x.xlsx Set=nu rng=ExcelTab!A1 rdim=2 cdim=0
$ife errorlevel<>0 $abort 'problem with gdxxrw'
$gdxin x.gdx
$load n<nu.dim1 u<nu.dim2 nu

display n,u,nu;
I hope this helps!