About the General Text Parser Adapter

You use the General Text Parser adapter to read values from a region of a text file and map the values to parameters or to write the values of parameters to a region of a file.

This page discusses:

Parsing and Mapping

You can read data from a specified row and column in the text file and map the data to the value of a scalar parameter or to the values of specified elements of an array parameter. Alternatively, if the content of the file is changing, say after each iteration of a design of experiments study, you can create a marker and read from or write to a position in the file relative to the marker.

You can edit a parsing action that you have created. For example, you can change the selection of the words or the range of characters in the text file that is being parsed, and you can change the parameter to which you are mapping.

While you are defining the mapping between parameter values and regions of a text file, Optimization Process Composer displays messages indicating the actions that will be performed when the general text parser runs. Optimization Process Composer uses color highlighting to help you distinguish between text that was selected for read mapping and text that was selected for write mapping. Text that was selected for a marker is also highlighted.

Reading From a File to a Scalar Parameter

You can read a single value from a specified location in an ASCII text file and map it to a scalar parameter. For example, the following figure shows selected text from a file being mapped to two scalar parameters—HDistance and VDistance.

The type of the parameter can be real, integer, string, Boolean, or timestamp. If you are mapping to a parameter of type timestamp, the selected text must be in a valid format when the text parser runs; for example, MM/dd/yyyy HH:mm:ss. You cannot map to an object parameter.

When you are reading values from a file, you can specify the Failed Parser Value. Optimization Process Composer assigns this value to a parameter if it fails to parse the specified text; such a failure would occur, for example, if you are mapping to an integer parameter and the text contains non-numeric characters. If you do not specify a failed parser value, Optimization Process Composer does not assign a value to the parameter.

You can read the value of a parameter from only one location in the file.

Reading From a File to an Array Parameter

You can read a range of values from columns at a specified location in an ASCII text file into a one or two-dimensional array parameter. For example, the following figure shows selected text from three columns of a file being mapped to three one-dimensional array parameters—n, X, and Y.

When you map to an array parameter, the parameter must be of type real, integer, or string. You can map a column of an ASCII file to a one-dimensional array, or you can map two or more columns to a two-dimensional array.

If you are parsing columns of data in the text file to a one-dimensional or two-dimensional array parameter, and the length of the columns is changing between iterations, you can specify that the dimensions of the array are resizable. When you read data from the text file, Optimization Process Composer adjusts the size of the array based on the number of rows that can be read from the file.

Alternatively, you can specify the number of values to be read into the array parameter. The number of values to read must be less than or equal to the size of the array parameter.

If desired, you can read a single value into a specified element of an array parameter.

Writing a Scalar Parameter to a File

You can write the value of a scalar parameter to a specified location in an ASCII text file when the general text parser runs. The type of the parameter can be real, integer, string, Boolean, or timestamp. You cannot write an object parameter. If you are writing a real parameter to a file, you can specify the format of the text using standard C-programming style. For example:

Parameter Value Format Result
879 %05d 000879
44.348 %+8.2f 44.35
44.55 %-.1e 4.5e+01
544666.678 %-10.8g 544666.68
544666.678 %-11.5G 5.4467E+05
544666.678 %10.6g 544667

You can map a parameter to multiple locations in the file. The parser writes the same parameter value to each of the specified locations.

Writing an Array Parameter to a File

You can write the values of array parameters into columns at a specified location in an ASCII text file, as long as the array parameter is of type real, integer, or string.

If the length of the columns is changing between iterations, you can specify that the dimensions of the array are resizable. When you are writing data to the text file, Optimization Process Composer replaces the columns of text in the file with the content of the resizable array.