SPLIT stage v1.1

Pipelines v2.0

 

Purpose, Operands, Streams used, Usage notes, Examples, See also

Home

 

Syntax

 
            _AT_____________________________________________
>>__SPLIT__|________________________________________________|__________________________><
           |   _AT_____                                     |
           |__|________|__ _________ __ _________________ __|
              |_BEFORE_|  |_ANYCase_|  |_charrange_______|
              |_AFTER__|               |_STRing_ _string_|
                                       |_REGexp_|
                                       |_ANYof__|

 

Purpose

 

Use the SPLIT stage to divide input records into multiple output records. SPLIT reads records from its primary input stream; splits the records and writes the resulting records to its primary output stream. If no operands are specified; SPLIT divides records at whitespace characters (both space (X’20) and tab (X’09’) characters are considered to be whitespace) and discards them. If you only specify the AT, BEFORE or AFTER operands; records are split at whitespace characters, before whitespace characters or after whitespace characters, respectively. With additional operands, records are split relative to occurrences of a specified target.

 

Operands

 

    

AT

causes input records to be split at the specified target. The target characters are discarded. AT is the default.

 

    

BEFORE

causes input records to be split before the specified target. The target characters are retained.

 

    

AFTER

causes input records to be split after the specified target. The target characters are retained.

If you specify AFTER with STRING, the records are split after any columns that contain the last character of the string.

 

    

ANYCase

specifies that charrange or string is compared with the input record in uppercase. In effect this means that a non-case-sensitive comparison is made when selecting characters that cause the records to be split.

 

    

charrange

is a character range. A split occurs when any one of the characters in the range is matched.

 

    

STRing

specifies that the string operand is a literal string of characters to locate. A split occurs only when the entire string is matched.

 

    

REGexp

specifies that the string operand is a regular expression of characters to locate. A split occurs when the expression is matched.

 

    

ANYof

specifies that the string operand is a list of characters to locate. A split occurs when any one of the characters in the list is matched.

 

 

string
is a string to locate.

 

Streams used

 

The following streams are used by the SPLIT stage:

 

Stream

Action

 

 

Primary input stream

SPLIT reads records from its primary input stream.

Primary output stream

After splitting the input records into multiple records, SPLIT writes the resulting records to its primary output stream.

 

Usage notes

 

     1)

SPLIT does not delay the records.

 

     2)

If the SPLIT stage discovers that its primary input or output streams are not connected, the SPLIT stage ends.

 

     3)

SPLIT copies null input records to its primary output stream. It does not generate null output records.

 

     4)

SPLIT verifies that its secondary input and output streams are not connected and then begins execution.

 

Examples

 

The following example utilises the SPLIT stage command in a pipeline which determines the number of bytes that could be saved by removing trailing whitespace.

 

**** Top of file ****
01 Address Rxpipe
02
03 ‘pipe < myfile.txt ‘,
04    ‘| locate’,                         /* Discard blank-lines. */
05    ‘| xlate w-1;* x20 @ x09 @’,        /* Change spaces/tabs to at(@) chars. */
06    ‘| split before str /@/’,           /* Split at each at(@), start new record. */
07    ‘| strip trailing anyof /@/’,       /* Reduce records to length zero. */
08    ‘| nlocate 1’,                      /* Select only null/empty records. */
09    ‘| count’,                          /* Count the records. */
10    ‘| specs /The number of bytes which could be saved is:/ 1 1-* nw’,
11    ‘| cons                            /* Display the result. */
12
13 Exit 0
**** End of file ****

 

See also

 

Reference the following links for additional information:

 
CHOP, JOIN, PAD, STRIP
 

History of change

 

Version

Action

Description

 

 

 

1.1

Added

Support for the REGEXP operand; which specifies that the string operand is interpreted as a regular expression.