csv2gdx10.gms : CSVRead Example 10 - Reading Set Elements with explanatory Text

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 CSVRead Documentation.

Keywords: CSVRead, 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 CSVRead 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 CSVRead Documentation.

Keywords: CSVRead, 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, CSVRead does not read explanatory text (nor did we specified a
* column to get the text strings from)
$callTool csvread data.csv id=abOnlyUELs index=1,2 trace=0 gdxout=onlyUELs.gdx
$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
$callTool csvread data.csv id=abWithExpText index=1,2 text=3 trace=0 gdxout=withExpText.gdx
$ifE errorLevel<>0 $abort Problems reading CSV file with text option!

Set abWithExpText;
$gdxIn withExpText.gdx
$load abWithExpText
$gdxIn
display abWithExpText;