csv2gdx5.gms : CSV2GDX Example 5 - Reading more than one Parameter from a single Input File

Description

This model demonstrates how to read more than one parameter from in single CSV
file. However, this cannot be done with CSV2GDX directly, since CSV2GDX returns
one single parameter. The data must be split later on.

This model is referenced in "Getting Started Example 4 - Reading more than one
parameter from a single input file" from the CSV2GDX Documentation.

Keywords: CSV2GDX, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : csv2gdx5.gms   includes :  csv2gdx5.gms

$title CSV2GDX Example 5 - Reading more than one Parameter from a single Input File (CSV2GDXE5,114)

$onText
This model demonstrates how to read more than one parameter from in single CSV
file. However, this cannot be done with CSV2GDX directly, since CSV2GDX returns
one single parameter. The data must be split later on.

This model is referenced in "Getting Started Example 4 - Reading more than one
parameter from a single input file" from the CSV2GDX Documentation.

Keywords: CSV2GDX, data exchange, GAMS language features
$offText

$onEcho > networkData.csv
plant;station;length;minCap;maxCap;stage;cost
p1;s1;100;50;100;1;1200
p1;s2;75;35;65;1;500
p1;s1;100;100;150;2;1800
p2;s1;150;50;100;1;1400
p2;s1;150;100;150;2;2000
p2;s1;150;150;200;3;2350
p2;s2;75;25;50;1;600
p2;s2;75;50;75;2;800
p3;s1;80;40;100;1;1050
$offEcho

$call csv2gdx networkData.csv id=dataPar useHeader=y fieldSep=semiColon index=1,2,6 values=4,5,7 trace=0 
$ifE errorLevel<>0 $abort Problems reading networkData.csv!

Set plant, station, stage;

* CSV2GDX reads all data into one single parameter. To split the data later on,
* it is necessary to declare the dummy parameter dataPar at first

Parameter
   dataPar
   minCap(plant,station,stage)
   maxCap(plant,station,stage)
   cost(plant,station,stage);

$gdxIn networkData.gdx
$load plant   = dim1
$load station = dim2
$load stage   = dim3
$load dataPar
$gdxIn

minCap(plant,station,stage) = dataPar(plant,station,stage,'minCap');
maxCap(plant,station,stage) = dataPar(plant,station,stage,'maxCap');
cost(plant,station,stage)   = dataPar(plant,station,stage,'cost');

display plant, station, stage, minCap, maxCap, cost;