AWK Scripts for Loading Text Files into GAMS

Uwe A. Schneider

last modified May 2012

Other GAMS interfaces  from/to:  ShadeMap   Gnuplot   Stata    Powerpoint    Html    Awk



Many data are stored in text files but are not compatible with GAMS. Such data include geographic data, various model output, and statistics. AWK is a text processing program which is integrated in GAMS. It can help you to convert text file based information if this information is organized in a systematic way. As long as you can perceive a rule on which to process your data automatically, there is a high chance that you can formulate this rule as an awk script. The following tasks can easily be implemented in awk:

General Instructions

Awk scripting for GAMS through GAMSIDE usually involves four different files:

  1. A text format file with information (e.g. data.txt), from which you want to extract GAMS sets or parameters.
  2. A text file containing the awk script (e.g. script.awk). I use the extension .awk for these files but this is not required
  3. A *.gms file containing a statement to execute the awk script (e.g. $call awk -f script.awk data.txt > data.gms)
  4. An output file (e.g. data.gms which is produced by executing *.gms)

For help on awk scripts click here.



AWK scripting tips for GAMS users