csv2gdx9.gms : CSV2GDX Example 9 - Reading Options from an external File

Description

This example demonstrates how to read the parameters from an external text file.
The file distance.csv from will be processed with CSV2GDX while reading the
options from an external file named howToRead.txt.

This model is referenced in "Additional examples for extended use Example 8 -
Reading the options from an external file" from the CSV2GDX Documentation.

Keywords: CSV2GDX, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : csv2gdx9.gms   includes :  csv2gdx9.gms

$title CSV2GDX Example 9 - Reading Options from an external File (CSV2GDXE9,SEQ=118)

$onText
This example demonstrates how to read the parameters from an external text file.
The file distance.csv from will be processed with CSV2GDX while reading the
options from an external file named howToRead.txt.

This model is referenced in "Additional examples for extended use Example 8 -
Reading the options from an external file" from the CSV2GDX Documentation.

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

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

$onEcho > howToRead.txt
* These lines are interpreted as a comment
* This file specifies the options for reading distance.csv using CSV2GDX

id         = d
fieldSep   = semiColon
decimalSep = comma
index      = 1
useHeader  = y
values     = 2..lastCol
$offEcho

Set
   i(*) 'canning plants'
   j(*) 'markets';

$call csv2gdx distance.csv @howToRead.txt trace=0 
$ifE errorLevel<>0 $abort Problems reading CSV file!
$gdxIn distance.gdx
$load i = dim1
$load j = dim2

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