Contents - Index
The $Export directive provides a simple way of writing selected variables and/or constants to an ASCII file. This file can then be read by a $Import directive, the Open Lookup Table command in EES or by another application, such as a spreadsheet program. The filename extension controls the format of the file that is written. Allowable filename extensions are .CSV, .DAT, .TAB and .TXT.
If the filename extension is .CSV (comma-separated values), the data will be written as a CSV ASCII text file that is easily recognized by spreadsheet applications and by the $Import directive. In this format, each value is separated by a list separator character. If the filename extension is .TAB, values are separated with a tab character. If the filename extension is .TXT, EES will assume that the data should be written with header information in the EES Lookup file format that can be read directly by the Open Lookup Table command. The header information will include the name of the variable, its units, and its display format. Note that if a /H option is provided, header information will not be included. If the filename extension is .DAT or any other filename extension, values are separated with a tab.
The format of the $Export Directive is
$Export /A /C /D /F /H /L /N /Q /U /V 'FileName' Var1 Var2:E5 Var3:F2 Var4:A X[1..5] ...
The values of variables Var1, Var2, Var3, Var4 and 5 elements of array X are exported with the above $EXPORT directive. The variable can be separated by a list separator (, for US users, ; for European users) or a space. Note that numerical or string constants can also be supplied along with variable names. The example shows an optional format specification that can be appended to each variable name. The default situation without any format specification as shown for Var1 is to export the variable with 8 digits of precision in floating point format.
/A is optional. If present, it indicates that the values should be appended to the existing file, if it exists.
/C is optional. If present, the designated file will be cleared before each exporting operation. Normally, results are exported for each run in the Parametric table. If the /F option is not used, the exported data would be appended to data written for previous runs in the Parametric table. However, with the /C option, only the results from the last run in the Parametric table appear in the exported file. The /C option should not be used with the /A option.
/D is optional. If present, it indicates that the exported values are formatted to appear just as they do in the Solutions window unless a format specification is appended to the variable name.
/F is optional. Normally, results are exported for each run in the Parametric table. If the /F is present, only the results for the final run in the Parametric table will be exported. This option is ignored if the calculations do not involve the Parametric table.
/H is optional. if present, the header information that allows the .TXT file to be read into an EES Lookup file will not be written. This option is ignored for files having a filename extension other than .TXT.
/L is optional. If present, a carriage return - line feed will not be written after the last variable in the $Export directive is written. A comma, tab, semicolon or space will be written in its place, depending on the selected filename extension. Combined with the /A option, the /L option allows values from multiple $Export directives to be written on a single line.
/N is optional. If present, the value of each variable is written on a separate line. (This option should not be used with the /L option.)
/Q is optional. If present, the single quotes that normally surround string information will not be included.
/U is optional. If present, it indicates that the units of the exported values are exported with the values. Units are enclosed in brackets and are separated with a tab from the values.
/V is optional. If present, it indicates that the variable names of the exported values are exported with the values. The variable name precedes the value and is separated with a tab. Use the /N option to force each variable to be written on a separate line.
FileName can be either a string constant (within single quotes) or a string variable containing the name of the file that the values will be written to. If filename is specified to be 'CLIPBOARD', the output will be placed as delimited text on the clipboard. A maximum of 65,000 characters can be written to the clipboard.
Var1, Var2, X[1..5] represent variables that are used in the main section (not in a Module) of your EES program. Note that array range notation is supported.
The $Export directive can be placed anywhere in the Equations Window, including within Functions, Procedures, and Subprograms. Multiple $Export directives are permitted, and they will be evaluated in the order that they occur in the Equations Window after calculations are completed.
The Lookup command can be used to write (as well as read) values in the Lookup Table. Saving the Lookup table as a .CSV file also provides export capability, but the $Export/$Import and the $CopytoLookup directives are much more convenient for this purpose.
$Export T$ A,B,C:F4,D:FM
$Export 'CLIPBOARD' A,B,C:F4,D:FM
After solving, file C:\temp\junk.csv will be written with the following values (for the 32-bit license):
These values will also be placed on the clipboard from which they can be pasted into any application.
$EXPORT /Q /N /H 'C:\temp\Lines.txt' S$[1..N]
After solving, file C:\temp\Lines.txt will contain the following information. Note that the header information that normally is written in .TXT files has been excluded and each string is placed on a separate line.
y= 6 [W]
$export 'c:\temp\xport.dat' /d /u x,y
After solving, file C:\temp\xport.txt will contain the following information. Note that x and y were formatted with the auto display format and that a tab character appears before the value and its units. Values are also separated wtih a tab.
5 [Btu] 6 [W]
See also: $Import, $ExportText, Directives