### B.4 Import, export and memory management

The following statements are used to clear items from memory, save or load workspaces, and import or export items from/to text ﬁles.

 Syntax Arguments and performed function clear(A); Clears item with id value A from memory. A could be any of the following data types: matrix dataset model structure string or the keywords: all matrices datasets models structures strings The statement clear(all); clears all items from memory, while, for example, clear(matrices); clears all matrices from memory. save(s); Saves the current workspace (all items in memory) to the ﬁle speciﬁed by s. s must be a string containing the directory, ﬁlename and extension of the ﬁle to be saved. The path to the ﬁle speciﬁed in s can be absolute (eg. "C:/MyFiles/MyFolder/MyFile.bws") or relative to the current working directory (eg. "./MyFolder/MyFile.bws"). load(s); Loads a previously saved workspace from the ﬁle speciﬁed by s to the current workspace. The current workspace must be empty for the operation to proceed. s must be a string containing the directory, ﬁlename and extension of the ﬁle to be loaded. The path to the ﬁle speciﬁed in s can be absolute (eg. "C:/MyFiles/MyFolder/MyFile.bws") or relative to the current working directory (eg. "./MyFolder/MyFile.bws"). D = import(s $\left[$, d $\right]$); D = webimport(s $\left[$, d $\right]$); D is a dataset constructed by reading the contents of the ﬁle or URL speciﬁed in s. s must be a string specifying the directory, ﬁlename and extension of (in the case of import()) or the URL that points to (in the case of webimport()) the ﬁle which contains the data to be imported. In the case of import(), the path to the ﬁle can be absolute (eg. "C:/MyFiles/MyFolder/MyFile.csv") or relative to the current working directory (eg. "./MyFolder/MyFile.csv"). d is the delimiter used in the data ﬁle to separate values and must be equal to one of the following strings: "," ";" "∖t" The default value is comma (",") and is used for importing data from csv ﬁles. ";" and "∖t" can be speciﬁed to alter the default value separator to semicolon and tab, respectively. The variables in the ﬁle speciﬁed by s must be organized in columns, with the ﬁrst row containing the variable names. export(id, s $\left[$, d$\right]$); export(s1, s2 $\left[$, $\right]$); When used in the ﬁrst format, export(id, s $\left[$, d$\right]$);, the function exports the item in memory with id value id to the ﬁle speciﬁed in s. id must be the name of a dataset or matrix currently in memory (structures, models and strings cannot be exported). s must be a string containing the directory, ﬁlename and extension of the ﬁle to which the data are to be exported The path to the ﬁle speciﬁed in s can be absolute (eg. "C:/MyFiles/MyFolder/MyFile.csv") or relative to the current working directory (eg. "./MyFolder/MyFile.csv"). d is the delimiter used in the data ﬁle to separate values and must be a string with one of the following values: "," ";" "∖t" The default value is comma (,) and is used for exporting data to the csv format. ; and \t can be speciﬁed to alter the default value separator to semicolon and tab, respectively. When exporting a matrix, the values of the matrix are printed in the ﬁle speciﬁed in s. When exporting a dataset, the variable names are printed in the ﬁrst row of the ﬁle, before printing the actual values of the variables. When used in the second format, the function exports the graph contained in the ﬁgure window with title s1 to the ﬁle speciﬁed in string s2. The type of the exported graph (eps, png or jpeg) is determined by the extension of the ﬁle provided in s2. s1 must be a string equal to the name appearing on the title bar of the ﬁgure window, the contents of which are to be exported. s2 must be a string containing the directory, ﬁlename and extension of the ﬁle to which the graph will be exported. The path to the ﬁle speciﬁed in s2 can be absolute (eg. "C:/MyFiles/MyFolder/MyGraph.eps") or relative to the current working directory (eg. "./MyFolder/MyGraph.eps"). The argument allows setting the width and height of the exported ﬁgure, in pixels. For example, export([...],"width"=100,"height"=100); will set the width and height of the exported ﬁgure to 100 pixels. The default values for "width" and "height" are 400 and 250, respectively.