Description
This example demonstrates how to read explanatory text of set elements by using the option "text". This model is referenced in "Additional Examples for extended Use Example 9 - Reading Set Elements with explanatory Text" from the CSV2GDX Documentation. Keywords: CSV2GDX, data exchange, GAMS language features Dump some CSV data, set elements in the first two columns, explanatory text in the third and some values in the last columns
Category : GAMS Data Utilities library
Main file : csv2gdx10.gms includes : csv2gdx10.gms
$title CSV2GDX Example 10 - Reading Set Elements with explanatory Text (CSV2GDXE10,130)
$onText
This example demonstrates how to read explanatory text of set elements by using
the option "text".
This model is referenced in "Additional Examples for extended Use Example 9 -
Reading Set Elements with explanatory Text" from the CSV2GDX Documentation.
Keywords: CSV2GDX, data exchange, GAMS language features
$offText
* Dump some CSV data, set elements in the first two columns, explanatory text
* in the third and some values in the last columns
$onEcho > data.csv
a1,b1,explanatory text of a1.b1,10
a1,b2,explanatory text of a1.b2,20
a2,b1,explanatory text of a2.b1,30
a2,b2,explanatory text of a2.b2,40
$offEcho
* By default, CSV2GDX does not read explanatory text (nor did we specified a
* column to get the text strings from)
$call csv2gdx data.csv output=onlyUELs id=abOnlyUELs index=1,2 colCount=4 trace=0
$ifE errorLevel<>0 $abort Problems reading CSV file!
Set abOnlyUELs;
$gdxIn onlyUELs.gdx
$load abOnlyUELs
$gdxIn
display abOnlyUELs;
* Specify the column containing the explanatory text within the option "text"
* in order to get the set elements with corresponding explanatory text
$call csv2gdx data.csv output=withExpText id=abWithExpText index=1,2 text=3 colCount=4 trace=0
$ifE errorLevel<>0 $abort Problems reading CSV file with text option!
Set abWithExpText;
$gdxIn withExpText.gdx
$load abWithExpText
$gdxIn
display abWithExpText;