$title - Testing the valueDim Option (8,SEQ=753) $onText The valueDim option is tested on different data in combination with useHeader and autoCol. Contributor Jan-Erik Justkowiak, May 2018 $offText * Single value column $onEcho > withHeaderS.csv I,II a,1 b,2 c,3 $offEcho $onEcho > testValDim1.gms $log $log 1. With valueDim, with useHeader=Y, single value column $call gamstool csvread withHeaderS.csv id=d useHeader=Y index=1 values=2 valueDim=Y trace=0 gdxout=withHeaderS.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log Set dim1 / a, b, c /, dim2 / II /; Parameter d / a.II 1, b.II 2, c.II 3 /; $gdxOut temp.gdx $unLoad dim1 dim2 d $gdxOut $offEcho $call gams testValDim1.gms lo=%GAMS.lo% $ifE errorLevel<>0 $abort Something went wrong with testValDim1! $call gdxdiff withHeaderS.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running testValDim1! *------------------------------------------------------------------------------- $onEcho > noHeaderS.csv a,1 b,2 c,3 $offEcho $onEcho > testValDim2.gms $log $log 2. With valueDim, with useHeader=N, with autoCol, single value column $call gamstool csvread noHeaderS.csv id=d useHeader=N index=1 values=2 autoCol=c valueDim=Y trace=0 gdxout=noHeaderS.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log Set dim1 / a, b, c /, dim2 / c1 /; Parameter d / a.c1 1, b.c1 2, c.c1 3 /; $gdxOut temp.gdx $unLoad dim1 dim2 d $gdxOut $offEcho $call gams testValDim2.gms lo=%GAMS.lo% $ifE errorLevel<>0 $abort Something went wrong with testValDim2! $call gdxdiff noHeaderS.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running testValDim2! *------------------------------------------------------------------------------- $log $log 3. With valueDim, with useHeader=Y, with autoCol, single value column $call gamstool csvread withHeaderS.csv id=d useHeader=Y index=1 values=2 autoCol=c valueDim=Y trace=0 gdxout=withHeaderS.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log $call gdxdiff withHeaderS.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running 3.! *------------------------------------------------------------------------------- * Multiple value columns $onEcho > withHeaderM.csv I,II,III,IV,V a,d,1,4,7 b,e,2,5,8 c,f,3,6,9 $offEcho $onEcho > testValDim4.gms $log $log 4. With valueDim, with useHeader=Y, multiple value columns $call gamstool csvread withHeaderM.csv id=d useHeader=Y index=1,2 values=3..lastCol valueDim=Y trace=0 gdxout=withHeaderM.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log Set dim1 / a, b, c /, dim2 / d, e, f /, dim3 / III, IV, V /; Parameter d / a.d.III 1, a.d.IV 4, a.d.V 7, b.e.III 2, b.e.IV 5, b.e.V 8, c.f.III 3, c.f.IV 6, c.f.V 9 /; $gdxOut temp.gdx $unLoad dim1 dim2 dim3 d $gdxOut $offEcho $call gams testValDim4.gms lo=%GAMS.lo% $ifE errorLevel<>0 $abort Something went wrong with testValDim4! $call gdxdiff withHeaderM.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running testValDim4! *------------------------------------------------------------------------------- $onEcho > noHeaderM.csv a,d,1,4,7 b,e,2,5,8 c,f,3,6,9 $offEcho $onEcho > testValDim5.gms $log $log 5. With valueDim, with useHeader=N, with autoCol, multiple value columns $call gamstool csvread noHeaderM.csv id=d useHeader=N index=1,2 values=3,4,5 autoCol=c valueDim=Y trace=0 gdxout=noHeaderM.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log Set dim1 / a, b, c /, dim2 / d, e, f /, dim3 / c1*c3 /; Parameter d / a.d.c1 1, a.d.c2 4, a.d.c3 7, b.e.c1 2, b.e.c2 5, b.e.c3 8, c.f.c1 3, c.f.c2 6, c.f.c3 9 /; $gdxOut temp.gdx $unLoad dim1 dim2 dim3 d $gdxOut $offEcho $call gams testValDim5.gms lo=%GAMS.lo% $ifE errorLevel<>0 $abort Something went wrong with testValDim5! $call gdxdiff noHeaderM.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running testValDim5! *------------------------------------------------------------------------------- $log $log 6. With valueDim, with useHeader=Y, with autoCol, multiple value columns $call gamstool csvread withHeaderM.csv id=d useHeader=Y index=1,2 values=3,4,5 autoCol=c valueDim=Y trace=0 gdxout=withHeaderM.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log $call gdxdiff withHeaderM.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running 6.! *------------------------------------------------------------------------------- $onEcho > testValDim7.gms $log $log 7. Check if valueDim=Y is ignored if there is no value column $call gamstool csvread withHeaderS.csv id=d useHeader=Y index=1 valueDim=Y trace=0 gdxout=withHeaderS.gdx $ifE errorLevel<>0 $abort Error: should have succeeded! $log Set dim1 / a, b, c /; Alias (dim1,d); $gdxOut temp.gdx $unLoad dim1 d $gdxOut $offEcho $call gams testValDim7.gms lo=%GAMS.lo% $ifE errorLevel<>0 $abort Something went wrong with testValDim7! $call gdxdiff withHeaderS.gdx temp.gdx > %system.nullfile% $ifE errorLevel<>0 $abort Data is not correct after running testValDim7! *-------------------------------------------------------------------------------