<< Click to Display Table of Contents >>

Navigation:  Gekko commands >


Previous pageReturn to chapter overviewNext page

The OPEN command opens databanks. In general, there are (potentially) the following databanks in Gekko:












Another databank



Another databank






Last databank






More info on this databank list on the databank search page. The first-position databank can always be referred to by for instance first:x, and the reference databank by ref:x.


In sim-mode, the order in the above list is not significant, since all banks that are not the first-position or local/global databank must be referred to by either bankname (like b2:x) or operators (like PRT<m>x;, to print the difference between first:x and ref:x). In other modes, for instance data-mode, Gekko will search for variables in the databanks shown in the 'Searchable' column. Note here that the Ref databank is never searchable, since the purpose of the Ref databank is to ease different kinds of comparisons.


When looking for a variable x in a command (for instance PRT x; or at the right-hand side of an expression (for instance = x;), Gekko will look first in the Local databank (if it contains variables), then in the first-position databank (often called Work), then in the second-position, third-position etc. databanks, and finally in the Global databank. The Local databank is used to store temporary variables, for instance variables used in functions and procedures, whereas the Global databank is used to store permanent variables that can survive a RESET or RESTART. These databanks are created at Gekko startup, but they are not shown in the databank list (F2) if they are empty. The same goes for the Ref databank, which is not shown in the F2 list if empty. Therefore, when Gekko starts up in a clean state, only the first-position databank (default: Work) is shown in the F2 list.


The OPEN command reads timeseries from a databank file into a databank with the same name as the file (minus the extension). A databank opened in the way is called a 'named' databank (in contrast to READ which operates on the first-position and/or reference databanks). Named databanks may be written to if they are opened with OPEN<edit>, and the databanks are closed with the CLOSE command.


NOTE: Gekko opens up databanks in the last position in the databank list. This behavior deviates from AREMOS and is only relevant for data- or mixed-mode users.


To open a databank file as the first databank in the list of databanks (cf. the F2 window), you may use OPEN<first> -- or OPEN<edit> if you want it in first position and editable. The first-position databank is the bank in which timeseries are found per default, and the reference databanks is often used for multiplier purposes (analyzing differences between two banks, for instance via MULPRT, PLOT<m>, etc.).


Variables in named (OPEN) databanks are referred to by means of colon (':'), for instance adam:x if the opened databank is the file adam.gbk, containing the variable x. Note that you can get a list of available in-memory databanks (including Work and Ref) by means of the F2 key.


The order in which normal OPEN databanks (that is, opened with OPEN, not for instance OPEN<edit>, OPEN<first> or OPEN<ref>) are opened is only of importance if OPTION databank search = yes is set (it is set to no as default in sim-mode, but set to yes as default in data-mode). So regarding a bank-less variable like x, it depends upon the databank search settings how x is searched for in the different open databanks (cf. the databank search page). The variable @x (same as ref:x) is always x taken from the reference databank, and adam:x is always x taken from the in-memory databank adam.


With OPTION databank search = yes, which is default, Gekko will search for a bank-less variable x first in the Local databank, then all numbered databanks in the F2 window (bank number 1, 2, and so on), and finally in the Global databank.






OPEN < EDIT  FIRST  LAST  POS=...  REF  SAVE=...  CREATE format  COLS DATEFORMAT=...  DATETYPE=... > filename1  AS  alias1, filename2  AS  alias2, ... ;



The databank is opened in first position, as editable. (See also OPEN<create>).


The databank is opened in first position, as non-editable (protected)


The databank is opened in last position, as non-editable (protected). This corresponds to the way databanks are opened with the OPEN command in Gekko versions 2.1.3 and later.


(Optional) Indicate an integer value. The databank is opened in the n-th position, as non-editable (protected)


With OPEN<save=no>, Gekko will not write the databank to file when it is CLOSEd, even if the databank contents has changed. In that way, you may change the contents of a databank in RAM only (that is, the data is changed while the databank is open and the session lasts), but without altering the underlying databank file (.gbk). See also CLOSE<save=no>.


If this option is set, Gekko will accept an OPEN<create>b1, even if b1.gbk does not exist beforehand. Regarding a non-existing file, this is similar to OPEN<edit>, the difference is that OPEN<edit> puts the bank in first position, as editable. The reason why <create> is not the default way of opening a databank is to avoid errors if a user misspells a databank name.


(Optional). Can be tsd, gbk, pcim, csv, prn, xls, xlsx. The default file format is gbk.


Filenames may be contain an absolute path like c:\projects\gekko\myfile, a relative path like \gekko\myfile.gbk, or be stated without a path. Filenames containing blanks and special characters should be put inside quotes. See more on filenames here.

If the filename is set to '*', you will be asked to choose the file in Windows Explorer.

The extension .gbk is automatically added, if it is missing.





(Optional). Only for .xlsx and .csv files: this indicates whether the timeseries are running downwards in columns. Note that for .csv files, you indicate this in the first 'cell' (date/name).



(Optional). These options control the date format for .xlsx and .csv files. DATEFORMAT can be either 'gekko' (default) or a format string like 'yyyy-mm-dd', and the latter may contain a first or last indicator, for instance 'yyyy-mm-dd last', which indicates for quarterly or monthly data that the last day of the quarter or month is used. DATETYPE can be either 'text' or 'excel'. In the former case, the dates are understood as text strings (for instance '2020q3' or '2020-09-30' for a quarterly date), and in the latter case (not relevant for .csv files), the date is understood as an Excel date, which basically counts the days since January 1, 1900. This number would correspond to 44104 for the date 2020-09-31, and can be shown in Excel in different ways depending upon date format settings, language settings, etc., but the internal number itself is unambiguous. [New in 3.0.5].


(Optional). The name that is used when referencing the databank. Default is the filename minus extension.







Opening a .gbk file called bk1 is done with


OPEN bk1;


or by




and then selecting the databank. Afterwards, you may reference variables in the databank by means of for instance:


PRT fy, @fy, bk1:fy;


This will print out the fy variable from the first-position, reference, and bk1 databanks. You may use an AS alias to shorten the databank name:


OPEN bk1 AS b;
PRT fy, @fy, b:fy;


Try pressing F2 to open up the databanks window. This window provides an overview regarding the different open databanks (including Work and Ref).


If you open up two databanks like this:


OPEN bank1;
OPEN bank2;


bank1 will show up above bank2 in the databank list, because the OPEN command puts databank in the last position on the list. The following yields the same:


OPEN bank1, bank2;


You may use OPEN<first>, OPEN<sec>, OPEN<pos=n>, OPEN<last> to open a databank in a specific position on the databank list (F2). The command OPEN<edit>mybank; is the same as OPEN<first>mybank; UNLOCK mybank; -- and in that case, a subsequent SERIES xx1 = 100; will put the series xx1 into mybank:


OPEN <edit> mybank;
SERIES xx1 = 100;
CLOSE mybank;


After the CLOSE command, the altered databank is automatically written to file, so mybank.gbk will contain the xx1 series.







To get an editable databank in the second position or below, OPEN it and use UNLOCK afterwards.


When reading, extension '.gbk' is automatically added if it is missing. Global time settings does not affect the OPEN command, so all the data in the .gbk file is read into the databank regardless of how the timeperiod is set in Gekko.


See the IMPORT command for more information on databank formats.


You can use SERIES ?; to see what kinds of series reside in all open databanks (including their frequencies).


Banks are opened as 'protected' (non-editable) as default, unless you use OPEN<edit> or unlock with UNLOCK (see LOCK/UNLOCK).


You may use the isopen() function to test if a particular databank is open.




Related options


OPTION databank file copylocal = yes; [yes|no]

OPTION databank search = no; [yes|no]

OPTION folder bank = [empty];

OPTION folder bank1 = [empty];

OPTION folder bank2 = [empty];





Related commands