Description
Contributor: Alexander Meeraus, October 2016
Small Model of Type : GAMS
Category : GAMS Test library
Main file : csv2gdx1.gms
$title Test csv2gdx on input containing spaces (CSV2GDX1,SEQ=697)
$onText
Contributor: Alexander Meeraus, October 2016
$offText
$onEcho > space.csv
,"a b",c d, e f
1,1,2,3
"2 3",4,5,6
4 5,7,8,9
6 7 ,10,11,12
$offEcho
$onEcho > easy.csv
,"a b","c d", "e f"
1,1,2,3
"2 3",4,5,6
"4 5",7,8,9
"6 7" ,10,11,12
$offEcho
set j / "a b","c d","e f" /
i / 1, "2 3","4 5","6 7" /
alias(u,uu,*);
table a(*,*)
$onDelim
$include easy.csv
$offDelim
display a;
parameter aa(*,*),aaa(*,*);
sets ii(*),jj(*),iii(*),jjj(*);
sets diffii ,diffjj; parameter diffaa;
sets diffiii,diffjjj; parameter diffaaa;
$call =csv2gdx easy.csv id=a output=easy.gdx useheader=y index=(1) values=(2..lastcol) trace=0
$if errorlevel 1 $abort Problem running csv2gdx on easy.csv
$gdxIn easy.gdx
$load ii=dim1 jj=dim2 aa=a
$gdxIn
diffii(u) = (i(u) - ii(u)) or (ii(u) - i(u));
diffjj(u) = (j(u) - jj(u)) or (jj(u) - j(u));
diffaa(u,uu) = a(u,uu) - aa(u,uu);
display diffii,diffjj,diffaa;
abort$(card(diffii)+card(diffjj) +card(diffaa)) "soemthing went wrong with easy";
$call =csv2gdx space.csv id=a output=space.gdx useheader=y index=(1) values=(2..lastcol) trace=0
$if errorlevel 1 $abort Problem running csv2gdx on space.csv
$gdxIn space.gdx
$load iii=dim1 jjj=dim2 aaa=a
$gdxIn
diffiii(u) = (i(u) - iii(u)) or (iii(u) - i(u));
diffjjj(u) = (j(u) - jjj(u)) or (jjj(u) - j(u));
diffaaa(u,uu) = a(u,uu) - aaa(u,uu);
display diffiii,diffjjj,diffaaa;
abort$(card(diffiii)+card(diffjjj) +card(diffaaa)) "soemthing went wrong with space";