-
Notifications
You must be signed in to change notification settings - Fork 2
Input‐Output information
atecon edited this page Jan 19, 2024
·
3 revisions
By means of the open
command, Gretl can open various file types as a dataset
Here is a simple example for opening a csv-dataset. First, a string is defined which is substituted via the @
symbol:
string filename = "PATH + FILENAME.csv"
open "@filename
Might be useful for storing numeric output in matrix form. See the mwrite
command for details.
You can easily store a matrix as a csv file. The advantage is that you can read-in that format easily into Excel or Gretl again. Here is an example on how store a matrix:
matrix m = mnormal(3, 2)
string filename = "PATH+FILENAME.csv"
store "@filename" --matrix=m
This stored matrix in csv format can be opened as a dataset again:
string filename = "PATH+FILENAME.csv"
open "@filename" --preserve
Assume you print some string, matrix or some other Gretl object. You store the textual printout as a txt-file by means of the outfile
command. The example prints the values of a matrix to the txt-file:
matrix m = mnormal(3, 2)
string filename = "PATH+FILENAME.txt"
outfile "@filename
printf "%12.2f\n", m
end outfile