Tables

<< Click to Display Table of Contents >>

Navigation:  Gekko User Guide > Data Management User Guide > Data reporting >

Tables

Previous pageReturn to chapter overviewNext page

The TABLE statement is used to call tables (.gtb files) designed in a special xml format. Tables are intended for the tabelling of timeseries, with quite a lot of special functionality regarding this. Tables can be produced in either text or html format, and can be shown in the Menu tab of the Gekko graphical user interface. (Note that after a table has been shown in Gekko, you may use the 'Copy' button to copy the cells to the clipboard, for successive pasting into e.g. a spreadsheet like Excel).

 

 
Simple example

 

We will try to construct a simple table with a few timeseries. First, we construct the table file (.gtb). You can use any text editor (for instance Notepad) to do this, try using edit demo.gtb;, after which an empty file shows up (click 'yes' to create a new file). Next, put the following into demo.gtb and save the file.

 

Gekko table file: demo.gtb
 

<?xml version="1.0" encoding="Windows-1252"?>
<gekkotable>
  <tableversion>1.0</tableversion>
  <table varformat="f9.0">
    <cols>
      <colborder/>
      <col txtalign="left"/>
      <col txtalign="right"/>
      <colborder/>
      <col type="expand" txtalign="center"/>
      <colborder/>
    </cols>
    <rows>
      <rowborder/>
      <row>
        <txt colspan="3">Table 1. Demo table</txt>
      </row>
      <rowborder/>
      <row>
        <txt/>
        <txt/>
        <date/>
      </row>
      <rowborder/>
      <row>
        <txt>Variable 1</txt>
        <txt>$</txt>
        <var>x1</var>
      </row>
      <row>
        <txt>Variable 2</txt>
        <txt>$</txt>
        <var>x2</var>
      </row>
      <row varformat="f9.2">
        <txt>Ratio</txt>
        <txt>$</txt>
        <var>x1/x2</var>
      </row>
      <rowborder/>
    </rows>
  </table>
</gekkotable>

 

Now, we can try showing the table:

 

reset;
time 2010 2017;
x1 = 15.5, 13.6, 14.3, 16.8, 15.3, 15.4;
x2 = 16.6, 12.7, 15.2, 15.6, 16.4, 15.9;
table demo;  //adds .gtb on its own

 

Result (shown in the "Menu" tab):

 

clip0097

Here, you may click the link 'Transform options' to transform the data (for instance the p button for percentage growth).

 

First of all, it is seen that the decimals are removed for x1 and x2, because of the tag varformat="f9.0". Here, f9.0 means floating point, 9 characters wide, 0 decimals. This varformat is set for the whole table at the top of the .gtb file, but is "overruled" in the x1/x2 row, where it is set to f9.2 (two decimals).

 

The table is designed by first stating <cols>, and then <rows>. Regarding the columns, we do not need to state a column for each year/period, but just a column that is "expandable".

 

Col 1: <col txtalign="left">. The first column is for showing the labels (for instance "Variable 1").

Col 2: <col txtalign="right"/>. The next column is for shown the variables/formulas (like "x1").

Col 3: <col type="expand">. The third column is an expandable column for the six years 2010-2015.

 

There are also some <colborder> tags to insert vertical borders/lines. So technically, you should think of the table as having three columns, where the last column is "expandable".

 

Next, we define the <rows>.

 

Row 1: The first row looks like this: <txt colspan="3">Table 1. Demo table</txt>. The colspan="3" tag means that the cell spans three columns, in effect merging these cells into one "super cell". Here, it should be noted that Gekko visualizes the table as having three columns in all (where the last column is expandable), so colspan="3" effectively also merges with all the date columns (2010-2015), so that the first row spans all columns of the table.

Row 2: The next row has these tags: <txt/><txt/><date/>, which means empty text for the first two columns, and then <date> tag to ask Gekko to show the dates (in this case: years) corresponding to the global data period 2010-2015.

Row 3: There are these tags: <txt>Variable 1</txt> <txt>$</txt> <var>x1</var>, so in the first column, the text Variable 1 is inserted, whereas the special $ in column two means that it should take the text from the next column, that is, insert the text x1. This is just to avoid repetitive typing. The last column uses a <var> (variable) tag to state the variable or expression for the expandable column.

Row 4: Just like row 3.

Row 5: Also just like row 3, but overruling the formatting, to show two decimals (f9.2).

 

In addition, there are some <rowborder> tags to insert horizontal borders/lines.

 

Note that you may use strings in {}-curlies inside the xml elements, for instance instance <txt>Table regarding the year {%year}</txt>.

 

 
More details

 

Tables can also be called from menus (see MENU). Menus are used to store and organize a collection of tables in tree-like structure for better overview (if there are many tables).

 

Instead of using Notepad or a similar text editor, you may alternatively use the in-built XML Notepad editor to edit the .gtb file, try xedit demo.gtb;, and see XEDIT. Use 'View' --> 'Expand All' to unfold all XML nodes for better overview, and use Ctrl+D to duplicate an XML node (including its children nodes).

 

clip0098

 

For more advanced users, you may ask Gekko to output the raw HTML code corresponding to the table, and together with PIPE<html>, and graphs stored in the .svg format (to produce these, use the syntax PLOT x1, x2 file = plot.svg;), you may construct html pages mixing text/explanations, tables, and plots. The Gekko demo plots are actually an example of an auto-constructed html page (this page does not, however, contain html tables). Html pages can be converted to pdf for easier distribution (for instance via mail).