Contents - Index


FORMAT (.fmt) file

 

A Format file can be provided with the $OPENLOOKUP directive or the OPENLOOKUP macro commands to read a LOOKUP file into a LOOKUP table in a specified manner.  The .fmt file provides the columns display format and optionally, the name and units of the data that are to read into the LOOKUP table.  It is useful only for .txt, .csv, and .dat file formats.  An example .fmt file is shown below.  A .fmt file is a text file and it can be created and edited in any text editor, e.g., Notepad.  Using Notepad, save the file as a .txt file and then change the file name extension to .fmt.  Note that a tab character must be used to separate each field. 

 

//this is a format specification for .tm2 files 

skip 1

2-3 F0 year

4-5 F0 Month

6-7 F0 Day

8-9 F0 Hour

10-13 A G_o W-hr/m^2

18-21 A G W-hr/m^2

24-27 A DNI W-hr/m^2

30-33 A G_D W-hr/m^2

68-71 A T_a*10 C

74-77 A T_dp*10 C

80-82 A RH %

85-88 A P_a millibar

96-98 A Wind m/s

 

Any row that begins with // is understood to be a comment and is not further considered by EES

 

One or more specifications can optionally be provided at the top of the format file in any order.  The possible specifications are

 

skip n

ReadHeaders

ReadUnits

Separator Tab  {Space, Comma, ;}

FixLFCR

AllowStrings

 

Skip n (where n is an integer) instructs  EES to skip the specified number of rows when reading the file.  This feature is useful to read around a header that may be included in the file.

 

ReadHeaders instructs EES to consider the first row in the file after the skipped rows to be the text in the header columns of the Lookup table.  Note that the number of characters in the header text (including units) is 32.

 

ReadUnits instructs EES to consider the row in the file after the headers to be the units that appear in the header columns of the Lookup table.  Note that the number of characters in the header text (including units) is 32.  The ReadUnits should be used with a ReadHeaders specification.

 

EES can usually determine the character that separates values in each row, but when the data file contains string information, the algorithm may fail.  In this case, you can specify the separator character.  Legal separator characters are any of the following words:  space  tab,  comma, or any single character such as ; 

 

FixLFCR is needed only when the text file to be opened was written on something other than the Window operating system.  Text files written in Windows terminate each line with carriage return (Ascii 13) and line feed (Ascii 1) characters.  Unix systems use a different convention.  Placing this specification in the format file will cause EES to read the file and rewrite it according to the Windows format.

 

AllowStrings will result in EES automatically setting a column in the Lookup table to be string format if it encounters a non-numerical character in the first row of data.  Otherwise an error will be issued if character data are encountered when the file is opened.

 

The remaining rows (which are optional) are all of the same form.  Each row has 4 fields separated by the Tab character.

 

The first field provides the range of columns that will be read with a hyphen (-) delimiting the start and end columns.

 

The second field provides a format specification which directs EES on how to display the data.  The following specifications are valid

 

 Fn display the data as fixed decimal showing n figures after the decimal point

 En display the data as floating decimal with n+1 significant figures

 A display the data and let EES automatically select the display format  

 S read the data as string input

 

The third and fourth fields are optional.  If present, they provide the name in the column header and the units.

 

Note that if no information is provided concerning the column numbers, EES will attempt to read the file in free-format using standard delimiters which may be tabs, commas or spaces.  As a example, the following format file will read TMY3 weather data files Note that these data files were apparently prepared on something other than the Windows operating system, necessitating the FixLFCR specification. However, the data items are separated with commas so it is not necessary to specify column numbers and free-format reading can be used.

 

//TMY3.FMT  read weather data files from https://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/tmy3/

FixLFCR

Skip 2 

AllowStrings