ReadTextFile (FPScript)

21.09.2021

Reads a data set from a text file. This is a deprecated function! Use the

Syntax

ReadTextFile(TextFile, FromLine, ToLine, FromColumn, ToColumn, DataMatrix, DataType, Comma, ColumnSeparator [ , SingleSeparator = FALSE ])

 

The syntax of the ReadTextFile 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.

FromLine

Number of the first line to be read.

Permitted data structures are scalar value. 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.

ToLine

Number of the last line to be read. If ToLine is equal to 0, the file is read through to the end.

Permitted data structures are scalar value. 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.

FromColumn

Number of the first column to be read.

Permitted data structures are scalar value. 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.

ToColumn

Number of the last column to be read.

Permitted data structures are scalar value. 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.

DataMatrix

Boolean value, which specifies that the data set is to be read as a data matrix.

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.

DataType

Specifies the data type in which the data set is to be read. For data in calendar time or time span format, a string with the date format is specified using the following characters:

Character

Meaning

Y

Year, two-digit or four-digit

M

Month (1 - 12)

D

Day (1 - 31)

h

Hour (0 - 23)

m

Minute (0 - 59)

s

Second (0-59)

UTC

Can be appended to the date format, in which case it specifies that the date values are to be interpreted as Universal Time Coordinated (UTC).

The argument DataType can have the following values:

Constant

Meaning

TYPE_INTEGER16

Data type code for a 16-bit integer.

TYPE_INTEGER32

Data type code for a 32-bit integer.

TYPE_INTEGER64

Data type code for a 64-bit integer.

TYPE_FLOATINGPOINT32

Data type code for a 32-bit floating point value.

TYPE_FLOATINGPOINT64

Data type code for a 64-bit floating point value.

TYPE_STRING

Data type code for a string.

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.

Comma

A Boolean value, which specifies that the comma ',' is the decimal separator for floating point values in the file. If Comma is equal to FALSE, then the function expects a period '.' as the decimal separator.

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.

ColumnSeparator

A string with the column separator characters used in the text file.

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

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.

SingleSeparator

A Boolean value. The value TRUE specifies that after every column separator, a change of columns is to be assumed. FALSE specifies that with subsequent column separators, only one change of columns is to be assumed.

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.

Remarks

Floating point values can contain an exponent, which must start with the letter 'E' or 'e', for instance, 1.23e-12. 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. ReadTextFile can read data series and data matrices. If you read several columns as a data series, the columns are appended to one another, from left to right.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

ReadTextFile("c:\\examples\\file.txt", 2, 0, 2, 2, FALSE, TYPE_FLOATINGPOINT64, TRUE, "\t", FALSE)

Reads the second column from the text file c:\examples\file.txt. It starts from the second line, and tabs are used for the column separator.

See Also

ReadTextData Function

Share article or send as email:

You might be interested in these articles