SNAKE stage v1.2

Pipelines v1.9

 

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

Home

 

Syntax

 
>>__ _SNAKE___ __numcols__| Align |__ ________ __ _________ __ ________ _______________><
    |_COLUMNS_|                      |_colsep_|  |_numrows_|  |_setsep_|
 
Align:
 
    _NOAlign__________
|__|__________________|_____________ ___________________________________________________|
   |        _Left___   _PAD SPACE_  |
   |_Align_|________|_|___________|_|
           |_Centre_|_|_PAD_char__|
           |_Right__|
 

Purpose

 

Use the SNAKE stage to reformat records into one or more matrices. Each matrix is of size numcols by numrows records. Each matrix is formed column by column where a column is made up of sequentially read input records. When the number of columns in a matrix equals numcols and there are more input records to read, the next matrix is formed using the same procedure. If numrows is not specified; the input records are formatted into 1 matrix with the smallest possible number of rows. If numrows is specified, each matrix is formed column by column until the number of columns equals numcols. 

 

If the number of input records is not evenly divisible by numcols or the number of input records is less than is needed to build a matrix of numcols; SNAKE will build a matrix that best fits the number of input records. In this case, if you do not specify numrows; SNAKE will build a matrix consisting of numcols or less, where the actual number of output columns-1 contain the same number of rows, with the last column containing the remaining records.

 

Operands

 

    

numcols

is an unsigned integer which specifies the number of columns in each matrix.

 

    

NOAlign

specifies that columns are not aligned; this is the default.

 

    

Align

specifies that columns are as wide as the length of the longest input record. By default the data is aligned on the left, padded with spaces on the right.

 

 

Left

specifies that data is aligned on the left, padded with spaces on the right.

 

Centre

specifies that data is aligned in the centre, padded with spaces on the left and the right.

 

Right

specifies that data is aligned on the right, padded with spaces on the left.

 

PAD

specifies that shorter length input records are extended with the given pad character.

 

 

char

is the pad character.

 

    

colsep

is a string to insert between columns.

 

    

numrows

is an unsigned integer which specifies the number of rows in each matrix.

 

    

setsep

is a string to write between matrices.

 

Streams used

 

The following streams are used by the SNAKE stage:

 

Stream

Action

 

 

Primary input stream

SNAKE reads records from its primary input stream.

Primary output stream

SNAKE writes the multicolumn records to its primary output stream.

 

Usage notes

 

     1)

SNAKE delays the records. SNAKE delays each set of (numcols *numrows) records.

 

     2)

If the SNAKE stage discovers that its primary output stream is not connected, the SNAKE stage ends.

 

     3)

If colsep is specified and it consists of only decimal numbers (0-9), you cannot specify a number as the delimiting character. For example:

 

snake 3 /7/ 2

 

is not equivalent to

 

snake 3 171 2
 

The first SNAKE stage builds a matrix that is 3 columns wide by 2 columns deep, with a column separator string of ‘7’. The second stage builds a matrix that is 3 columns wide by 171 rows deep. That is, 171 is processed as numcols rather than as a delimited string.

 

     4)

The following diagram shows how input data is formatted into a matrix if you specify SNAKE 3.(the spaces between the records are for illustration only)

 

 

The following diagram shows how the data is formatted if you specify SNAKE 2 2. (the spaces between the records are for illustration only)

 

 

     5)

If you specify numrows, then the first record of the output data in the first matrix contains records 1, numrows+1, 2*numrows+1, and so on. (For example, if numrows is 3, the first record in the output contains the records that are numbered 1, 4, 7, and so on.) Thus, if the input records have been sorted, then the output columns will be sorted downwards.

 

     6)

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

 

Examples

 

Building a matrix

 

See also

 

Reference the following link for additional information:

 

SPECS