csv2gdx3.gms : CSV2GDX Example 3 - Reading Semicolon separated Data

Description

This model demonstrates how to read CSV files with semicolon separated data
and comma separated decimals. Afterwards, the valueDim option is presented.

This model is referenced in "Getting Started Example 2 - Reading semicolon separated data"
from the CSV2GDX Documentation.

Keywords: CSV2GDX, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : csv2gdx3.gms   includes :  csv2gdx3.gms

$title CSV2GDX Example 3 - Reading Semicolon separated Data (CSV2GDXE3,SEQ=112)

$onText
This model demonstrates how to read CSV files with semicolon separated data
and comma separated decimals. Afterwards, the valueDim option is presented.

This model is referenced in "Getting Started Example 2 - Reading semicolon separated data"
from the CSV2GDX Documentation.

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

$onEcho > distance.csv
i;j;miles
seattle;new-york;2,5
seattle;chicago;1,7
seattle;topeka;1,8
san-diego;new-york;2,5
san-diego;chicago;1,8
san-diego;topeka;1,4
$offEcho

Set
   i 'canning plants'
   j 'markets';

* Reading the values of column three by adjusting the value option
$call csv2gdx distance.csv output=distanceOut.gdx id=d fieldSep=semiColon decimalSep=comma index=1,2 useHeader=y value=3 trace=0
$ifE errorLevel<>0 $abort Problems reading distance.csv!
$gdxIn distanceOut.gdx
$load i = dim1
$load j = dim2

Parameter d(i,j) 'distance in thousands of miles';
$load d
$gdxIn
display i, j, d;


* ValueDim option enabled
Set m 'measurement unit' / miles, km /;

Parameter dmod(i,j,m);

$call csv2gdx distance.csv output=distanceOut.gdx id=d fieldSep=semiColon decimalSep=comma index=1,2 useHeader=y value=3 valueDim=y trace=0 
$ifE errorLevel<>0 $abort Problems reading distance.csv with valueDim enabled!
$gdxIn distanceOut.gdx
$load dmod = d
$gdxIn
display dmod;

dmod(i,j,'km') = 1.852*dmod(i,j,'miles');
display dmod;