csv2gdx1.gms : Test gdxdump and csvread

Description

Test gdxdump and csvread


Category : GAMS Data Utilities library


Main file : csv2gdx1.gms   includes :  csv2gdx1.gms

$onText
Test gdxdump and csvread
$offText


set m /m1*m100/
    n /n1*n100/;
parameter A(m,n);
A(m,n)$(Uniform(0,1) <= 0.5)=uniform(0,1);
scalar rc;

execute_unload "x.gdx",A;

execute 'gdxdump x.gdx output=a1.csv symb=A format=csv cdim=y > %system.nullfile%';
execute 'gamstool csvread a1.csv gdxout=y1.gdx index=1 values=2..101 useheader=y id=A > %system.nullfile%';
rc=errorlevel;
abort$(rc <> 0)'CSVRead a1.csv had a problem';

execute 'gdxdump x.gdx output=a2.csv symb=A format=csv cdim=n header="" > %system.nullfile%';
execute 'gamstool csvread a2.csv gdxout=y2.gdx index=1,2 values=3 id=A > %system.nullfile%';
rc=errorlevel;
abort$(rc <> 0)'CSVRead a2.csv had a problem';

execute 'gdxdiff x.gdx y1.gdx ID=A eps=1e-10 > %system.nullfile%';
rc=errorlevel;
abort$(rc <> 0)'GDXDIFF no difference expected for Y1';

execute 'gdxdiff x.gdx y2.gdx ID=A eps=1e-10 > %system.nullfile%';
rc=errorlevel;
abort$(rc <> 0)'GDXDIFF no difference expected for Y2';