Copying etc.

<< Click to Display Table of Contents >>

Navigation:  Gekko User Guide > Data Management User Guide > Databanks and variables >

Copying etc.

Previous pageReturn to chapter overviewNext page

As mentioned in the user guide section on databanks, Gekko databanks can contain different types of variables. Such variables may be copied, rename, moved, etc. between databanks, cf. the following statements:

 

CLONE

Makes the Ref (reference) databank an exact copy of the first-position databank. The statement is often used for modeling, but can also be used for data management, when comparing two databanks.

COPY

Copies variables inside a databank or between databanks. COPY copies all observations of timeseries, unless COPY<respect> is used. Wildcards and ranges can be used.

DELETE

Deletes variables in a databank (by name or wildcards/ranges)

INDEX

Searches a databank for variables (with wildcards or ranges). Can also search inside array-series.

RENAME

Renames variables in a databank (by name or wildcards/ranges). Can also be used to move variables between databanks (without copying).

 

In general, regarding statements like the above, it should be noted that a seemingly all-encompassing wildcard like * will only match timeseries of the current frequency in the first-position databank. If you need, for instance, to match all timeseries (of the current frequency) in all databanks, use *:*, and to match all timeseries of all frequencies (in the first-position databank), use *!*. There are also special rules regarding matching of scalars and maps, cf. this page on wildcards.

 

Some examples:

 

copy x1 to x2;              //make x2 an exact copy of x1
copy <respect> x1 to x2;    //only for the global time period
copy #m1 to #m2;            //copies the *list* #m1 to the *list* #m2
copy {#m1} to {#m2};        //copies *elements* of #m1 to the *elements* of #m2
copy b1:x1 to b2:x2;        //copies between databanks
copy b1:x* to b2:*;         //using wildcards
copy b1:x*;                 //copies into the first-position databank

 

As with other statements, it should be remembered that copy #m1 to #m2; will copy the object #m1 itself (#m1 may or may not be a list) into the object #m2, whereas copy {#m1} to {#m2}; will copy the variables corresponding to the string names inside #m1 (#m1 must be a list) into the variables corresponding to the string names inside #m2.

 

About wildcards, there are some special rules regarding these in relation to the symbols %, #, and !, cf. the user guide page on lists (or a more detailed explanation of wildcard logic here).

 

The DELETE statement just deletes named variables in a databank, for instance:

 

delete x1, x2, x3;
delete b1:x1, b2:x2;
delete b2:x*;

 

RENAME has the same syntax as COPY, and the only difference between the two is that COPY clones objects/variables, whereas RENAME renames/moves them. For instance:

 

rename x1, x2 as y1, y2;   //renaming two variables
rename x* as y*;           //rename using wildcards

rename b1:x1 as b2:x1;     //moving the variable between banks

 

The INDEX statement searches for variables and returns the results as a list of string names. See more about INDEX on the user guide page on lists. Beware that the keys [Tab] or [Ctrl+Space] offer autocompletion on timeseries names (cf. here).