csv2gdx3.gms : CSVRead 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 CSVRead Documentation.

Keywords: CSVRead, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : csv2gdx3.gms   includes :  csv2gdx3.gms

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

Keywords: CSVRead, 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';

Parameter d(i,j) 'distance in thousands of miles';

* Reading the values of column three by adjusting the values option
$callTool csvread distance.csv id=d dimids=i,j fieldSep=semiColon decimalSep=comma index=1,2 useHeader=y values=3 trace=0
$ifE errorLevel<>0 $abort Problems reading distance.csv!

display i, j, d;

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

Parameter dmod(i,j,m);

$callTool csvread distance.csv id=dmod fieldSep=semiColon decimalSep=comma index=1,2 useHeader=y values=3 valueDim=y trace=0 
$ifE errorLevel<>0 $abort Problems reading distance.csv with valueDim enabled!

display dmod;

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