csv2gdx8.gms : CSV2GDX Example 8 - Reading an compressed encrypted Input File

Description

This model demonstrates how to read a compressed input file with an optional
password using CSV2GDX. The gzip program in the gbin sub-directory can be used
to compress and decompress a file, while Endecrypt compresses and encrypts an
input file.

Note: CSV2GDX can only read compressed and encrypted files, if they are
      compressed AND encrypted with Endecrypt!

This model is referenced in "Additional examples for extended use Example 7 -
Reading an compressed encrypted input file" from the CSV2GDX Documentation.

Keywords: CSV2GDX, data exchange, GAMS language features


Category : GAMS Data Utilities library


Main file : csv2gdx8.gms   includes :  csv2gdx8.gms

$title CSV2GDX Example 8 - Reading an compressed encrypted Input File (CSV2GDXE8,SEQ=117)

$onText
This model demonstrates how to read a compressed input file with an optional
password using CSV2GDX. The gzip program in the gbin sub-directory can be used
to compress and decompress a file, while Endecrypt compresses and encrypts an
input file.

Note: CSV2GDX can only read compressed and encrypted files, if they are
      compressed AND encrypted with Endecrypt!

This model is referenced in "Additional examples for extended use Example 7 -
Reading an compressed encrypted input file" from the CSV2GDX Documentation.

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

$onEcho > compressMe.csv
,new-york,chicago,topeka
seattle,2.5,1.7,1.8
san-diego,2.5,1.8,1.4
$offEcho

* Compress the file by calling gzip
$call gzip compressMe.csv -c > compressedFile.csv.gz
$ifE errorLevel<>0 $abort Problems compressing file with Gzip!

* Read the compressed file with CSV2GDX
$call csv2gdx compressedFile.csv.gz output=unCompressedGzipFile.gdx id=d index=1 useHeader=y values=2..lastCol trace=0
$ifE errorLevel<>0 $abort Problems reading compressed Gzip file!

* Compressing files with Endecrypt. If no password file is specified, Endecrypt
* compresses the file, but does not encrypt it. Note: the extension remains the same
$call cat compressMe.csv | endecrypt -W compressedFile.csv
$ifE errorLevel<>0 $abort Problems compressing the file with Endecrypt!

* Read the Endecrypt compressed file with CSV2GDX
$call csv2gdx compressedFile.csv output=unCompressedEndycryptFile.gdx id=d index=1 useHeader=y values=2..lastCol trace=0
$ifE errorLevel<>0 $abort Problems reading compressed Endecrypt file!

* By adding a password file, Endecrypt encrypts and compresses the input file
$echo Anton > passwordFile.txt
$call cat compressMe.csv | endecrypt -W compressedEncryptedFile.csv passwordFile.txt
$ifE errorLevel<>0 $abort Problems compressing or encrypting the file with Endecrypt!

* Read the compressed and encrypted input file with CSV2GDX
* Note: CSV2GDX can only read these files, if they are compressed and encrypted with Endecrypt
* i.e. reading .gz, .7z etc. files with CSV2GDX is not supported!
$call csv2gdx compressedEncryptedFile.csv output=unCompressedDecryptedFile.gdx password=Anton id=d index=1 useHeader=y values=2..lastCol trace=0 
$ifE errorLevel<>0 $abort Problems reading compressed encrypted file!