Description
This program tests the compile-time and execution-time usage of GAMS Tool CSVRead. The tool can write data from CSV directly to a GAMS symbol if the option -gdxout is not specified. Contributor: Vaibhavnath Jha, September 2024
Small Model of Type : GAMS
Category : GAMS Test library
Main file : csvread1.gms
$title 'Test GAMS Tool CSVRead' (csvread1,SEQ=965)
$onText
This program tests the compile-time and execution-time
usage of GAMS Tool CSVRead. The tool can write data from CSV
directly to a GAMS symbol if the option -gdxout is not specified.
Contributor: Vaibhavnath Jha, September 2024
$offText
$onEcho > data.csv
i,j,III,IV,V
a,d,1,4,7
b,e,2,5,8
c,f,3,6,9
$offEcho
Set i,j;
Parameter c(i,j);
* compile-time
$callTool.checkErrorLevel csvread data.csv id=c dimids=i,j index=1,2 values=lastCol useHeader=y
execute_unload 'out.gdx' c,i,j;
Set check_i /a,b,c/, check_j /d,e,f/;
Parameter check_c(i,j) /a.d 7, b.e 8, c.f 9/;
execute_unload 'check.gdx' check_c=c, check_i=i, check_j=j;
execute "gdxdiff out.gdx check.gdx > %system.NullFile%";
abort$errorlevel 'Unexpected data in c';
set attr /III, IV, V/;
Parameter d(i,j,attr);
* execution-time
executeTool.checkErrorLevel "csvread data.csv id=d index=1,2 values=3..lastCol useHeader=y";
execute_unload 'out.gdx' d;
parameter check_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/;
execute_unload 'check.gdx' check_d=d;
execute "gdxdiff out.gdx check.gdx > %system.NullFile%";
abort$errorlevel 'Unexpected data in d';