ReadTextData (FPScript)

21.09.2021

Reads one or more data sets from a text file.

Syntax

ReadTextData(TextFile, [ Schema ], [ ChannelIdentifier ], [ CalendarTime = FALSE ], [ Signal = FALSE ], [ DataRange = READDATAFILE_DR_COMPLETE ], [ RangeFrom ], [ RangeTo ] [ , Duration ])

 

The syntax of the ReadTextData function consists of the following parts:

Part

Description

TextFile

String with the path of the text file to be read.

Permitted data structures are scalar value. Supported data types are string (file name).

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Schema

Alias name of a schema stored in the project database that contains all of the settings necessary for importing, or the path of an XML schema stored on the hard drive, or all necessary settings as an XML string.

The argument Schema can have the following values:

Constant

Meaning

READTEXTDATA_SCHEMA_COMTRADE

Schema for reading IEEE Comtrade text files.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

ChannelIdentifier

Number of the channel (starting with 1) or channels to be read. If no channel number is specified, all channels are returned, or, if present, the selection from the chosen schema is used. If a scalar value is specified as ChannelIdentifier, the channel is returned as a data series or signal. Otherwise, the channels are returned as a list.

Permitted data structures are scalar value und data series. All integral data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

CalendarTime

Boolean value specifying that the time data are to be read as calendar times. Otherwise, the X component provides the time in seconds since the start of the measurement. This argument may not be supported for the selected format and in that case may be ignored.

Permitted data structures are scalar value. Supported data types are Boolean value.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FALSE.

Signal

Boolean value specifying that elements are to be read as signals. This argument may not be supported for the selected format and in that case may be ignored.

Permitted data structures are scalar value. Supported data types are Boolean value.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FALSE.

DataRange

Value that specifies the type of data range to create.

The argument DataRange can have the following values:

Constant

Meaning

READTEXTDATA_DR_COMPLETE

The full data range is read in.

READTEXTDATA_DR_FROMTO

The data range from RangeFrom to RangeTo will be read.

READTEXTDATA_DR_FROMDURATION

The data range from RangeFrom to RangeFrom + Duration will be read.

READTEXTDATA_DR_DURATIONLAST

The data range with the duration Duration up to the last value will be read.

READTEXTDATA_DR_FIRSTDURATION

The data range with the duration Duration from the first value on will be read.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value READDATAFILE_DR_COMPLETE.

RangeFrom

Absolute or relative time of the first value to read if the data are to not be read out from the beginning. If the X data set contains calendar time values, a calendar time value is expected here; otherwise a floating point value is expected. If the argument is not specified or no X data set is assigned to the data sets, the data are read from the starting from the first value.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

RangeTo

Absolute or relative time of the first value to read if the data are not read to the end. If the X data set contains calendar time values, a calendar time value is expected here; otherwise a floating point value is expected. If the argument is not specified or no X data set is assigned to the data sets, the data are read up to the last value.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Duration

Duration of the data range. This value must be specified if the element DataRange has the value READTEXTDATA_DR_FROMDURATION, READTEXTDATA_DR_DURATIONLAST or READTEXTDATA_DR_FIRSTDURATION when viewed as a whole. This argument is only supported if an X data set has been specified.

Permitted data structures are scalar value. All real data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

If a file is imported using the Text Data Import Wizard, then it is possible to save the schema with the settings in the template database. In this case, the alias name can be used to access the settings. If the settings are not stored as a schema, you can also pass the settings directly in the form of an XML string of the function. You can save a stored schema in an XML file in the Organizer dialog box. You can also directly access this type of XML file in ReadTextData. If an entry in the file cannot be interpreted as a number, then a void floating point value is entered at the corresponding location in the result.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

ReadTextData("c:\\examples\\file.txt", "", 2)

Reads the second channel from the text file c:\examples\file.txt. Default settings are used for the import.

See Also

Text Data Import Wizard

Data Import

Share article or send as email:

You might be interested in these articles