Description
CSVRead is tested on data where the field separators are mixed up with single and double quotes inside the UELs. Note: While "'someString'" is interpreted equally by CSVRead and GAMS, CSVRead will fail when reading the reverse '"someString"'. However, besides the message "Bad Uel Count", no error is reported. This issue is not included in the example below! Contributor: Jan-Erik Justkowiak, March 2018
Small Model of Type : GAMS
Category : GAMS Test library
Main file : csv2gdx3.gms
$title CSVRead - Testing the Behavior of quoted Field Separators (CSV2GDX3,SEQ=747)
$onText
CSVRead is tested on data where the field separators are mixed up with
single and double quotes inside the UELs.
Note: While "'someString'" is interpreted equally by CSVRead and GAMS,
CSVRead will fail when reading the reverse '"someString"'. However,
besides the message "Bad Uel Count", no error is reported.
This issue is not included in the example below!
Contributor: Jan-Erik Justkowiak, March 2018
$offText
$onEcho > data.csv
"'x,y'", 'y,z', "x, z', a", d', "e, ", f"
1,2,3,4,5,6,7
$offEcho
Set label;
Parameter a;
$call gamstool csvread data.csv id=x useHeader=y values=1..lastCol trace=0 gdxout=data.gdx
$ifE errorLevel<>0 $abort Problems reading data with CSVRead!
$gdxIn data.gdx
$load label = dim1
$load a = x
Set labelc / "'x,y'", "'y", "z'", "x, z', a", "d'", "e, ", 'f"' /;
Alias (u,*);
display label, labelc, u;
Parameter ac
/
"'x,y'" 1
"'y" 2
"z'" 3
"x, z', a" 4
"d'" 5
"e, " 6
'f"' 7
/;
display a, ac;
Set difflabel;
Parameter diffa;
difflabel(u) = (label(u) - labelc(u)) or (labelc(u) - label(u));
diffa(u) = ac(u) - a(u);
display difflabel, diffa;
abort$(card(difflabel) + card(diffa)) "Something went wrong with CSVRead!";