CSE User's Manual

California Simulation Engine

4.56 IMPORTFILE

IMPORTFILE allows specification of a file from which external data can be accessed using the import() and importStr() functions. This allows external values to be referenced in expressions. Any number of IMPORTFILEs can be defined and any number of import()/importStr() references can be made to a give IMPORTFILE.

Import files are text files containing an optional header and comma-separated data fields. With the header present, the structure of an import file matches that of an EXPORT file. This makes it convenient to import unmodified files EXPORTed from prior runs. The file structure is as follows (noting that the header in lines 1-4 should not be present when imHeader=NO) –

LineContentsNotes
1runTitle, runNumberread but not checked
2timestampin quotes, read but not checked
3title, freqshould match imTitle and imFreq (see below)
4colName1, colName2, …comma separated column names optionally in quotes
5 ..val1, val2, …comma separated values (string values optionally in quotes)

Example import file imp1.csv

    "Test run",001
    "Fri 04-Nov-16  10:54:37 am"
    "Daily Data","Day"
    Mon,Day,Tdb,Twb
    1,1,62.2263,53.2278
    1,2,61.3115,52.8527
    1,3,60.4496,52.4993
    1,4,60.2499,52.4174
    1,5,60.9919,52.7216
    1,6,61.295,52.8459
    1,7,62.3178,53.2654
    1,8,62.8282,53.4747
    (... continues for 365 data lines ...)

Example IMPORTFILE use (reading from imp1.csv)

    // ... various input statements ...

    IMPORTFILE Example imFileName="imp1.csv" imFreq=Day imTitle="Daily Data"
    ...
    // Compute internal gain based on temperature read from import file.
    // result is 3000 W per degree temperature is above 60.
    // Note gnPower can have hourly variability, but here varies daily.
    GAIN gnPower = 3000 * max( 0, import(Example,"Tdb") - 60) / 3.412
    ...

Notes

imName

Name of IMPORTFILE object (for reference from Import()).

UnitsLegal RangeDefaultRequiredVariability
63 charactersnoneNoconstant

imFileName=string

Gives path name of file to be read. If directory is specified, CSE first looks for the file the current directory and searches include paths specified by the -I command line parameter (if any).

UnitsLegal RangeDefaultRequiredVariability
file name, path optionalnoneYesconstant

imTitle=string

Title expected to be found on line 3 of the import file. A warning is issued if a non-blank imTitle does not match the import file title.

UnitsLegal RangeDefaultRequiredVariability
Text stringnoneNoconstant

imFreq=choice

Specifies the interval at which CSE reads from the import file. Data is read at the beginning of the indicated interval and buffered in memory for access in expressions via import() or importStr().

UnitsLegal RangeDefaultRequiredVariability
YEAR, MONTH, DAY, HOUR, or SUBHOURnoneYesconstant

imHeader=choice

Indicates whether the import file include a 4 line header, as described above. If NO, the import file should contain only comma-separated data rows and data items can be referenced only by 1-based column number.

UnitsLegal RangeDefaultRequiredVariability
YES NOYESNoconstant

imBinary=choice

Adds the possibility to output the file as a binary option.

UnitsLegal RangeDefaultRequiredVariability
YES NONoNoconstant

endImportFile

Optionally indicates the end of the import file definition. Alternatively, the end of the import file definition can be indicated by END or by beginning another object.

UnitsLegal RangeDefaultRequiredVariability
noneNoconstant

Related Probes: