|
Rutherford's CSV put: Gams2csv |
Top Previous Next |
|
GAMS users do not have to do put file programming to move data in CSV format. Rather they can use a libinclude routine called Gams2csv developed by Rutherford and associates at the University of Colorado. That program and a write-up is available at http://www.mpsge.org/gams2csv/gams2csv.htm. Gams2csv is invoked as follows:
FILE localname /externalname/; PUT localname; $LIBInclude gams2csv [row domain [column domain] ] item[.suffix] [item[.suffix] ...]
$setglobal zeros yes
$setglobal prefix text Example: put 'x without domain' /; $libinclude gams2csv x put / 'x with lesser domain for i' //; $libinclude gams2csv lessi x put / 'y without domain' //; $libinclude gams2csv y put / 'y with lesser domain for i and j' //; $libinclude gams2csv lessi,lessj k y put / 'z without domain' //; $libinclude gams2csv z put / 'z with lesser domain for j and k' //; $libinclude gams2csv i,lessj,lessk z
which yields the output
x without domain "x","A one-dimensional vector." ,"i1",1.7174713200000E-01 ,"i2",8.4326670800000E-01 x with lesser domain for i "x","A one-dimensional vector." ,"i1",1.7174713200000E-01 y without domain "y","A three dimensional array written with column headers" ,,,"k1","k2","k3" ,"i1","j1",3.0113790400000E-01,2.9221211700000E-01,2.2405286700000E-01 ,"i1","j2",3.4983050400000E-01,8.5627034700000E-01,6.7113723000000E-02 ,"i1","j3",5.0021066900000E-01,9.9811762700000E-01,5.7873337800000E-01 ,"i2","j1",9.9113303900000E-01,7.6225046700000E-01,1.3069248300000E-01 ,"i2","j2",6.3971875900000E-01,1.5951786400000E-01,2.5008053300000E-01 ,"i2","j3",6.6892860900000E-01,4.3535638100000E-01,3.5970026600000E-01 y with lesser domain for i and j "y","A three dimensional array written with column headers" ,,,"k1","k2","k3" ,"i1","j1",3.0113790400000E-01,2.9221211700000E-01,2.2405286700000E-01 z without domain "z","A three dimensional array written in list form" ,,,"k1","k2","k3" ,"i1","j1",3.0113790400000E-01,2.9221211700000E-01,2.2405286700000E-01 ,"i1","j2",3.4983050400000E-01,8.5627034700000E-01,6.7113723000000E-02 ,"i1","j3",5.0021066900000E-01,9.9811762700000E-01,5.7873337800000E-01 ,"i2","j1",9.9113303900000E-01,7.6225046700000E-01,1.3069248300000E-01 ,"i2","j2",6.3971875900000E-01,1.5951786400000E-01,2.5008053300000E-01 ,"i2","j3",6.6892860900000E-01,4.3535638100000E-01,3.5970026600000E-01 z with lesser domain for j and k "z","A three dimensional array written in list form" ,"i1","j1","k2",2.9221211700000E-01 ,"i2","j1","k2",7.6225046700000E-01 ,"i3","j1","k2",0.0000000000000E+00 |