Top
PowerBSORT V7.0 User's Guide
FUJITSU Software

3.2.10 Key field option (-key-def)

This specifies the key fields.
A key field is composed of position, length, data format, and operation.
Two or more key fields can be specified at the same time. When two or more key fields are specified, key field is delimited by the comma (-key-def,key-def). Moreover, two or more specification of one following the specification of the previous key field (-key-def key-def), and the key field options (-key-def -key-def) can be specified. If the specification of key fields is omitted, the whole records is considered to be a key field and sorted in ascending order of the code. To omit the key field specification and sort them in descending order, use the Descending option (-r).

Note

The key field cannot be omitted for text file CSV format and text file TSV format.

Format

-key-def [ ,key-def ...]

pos

This specifies the position of the key field.
To specify the binary files and text file fixed fields, specify the byte position where the head of the record was assumed to be 0. For the specification of the text file floating field, text file CSV format, and text file TSV format, specify the field number counted from 0.

len

This specifies the length of the key field in the number of bytes.
For the text file floating field specification, text file CSV format, and text file TSV format, process with the length specified here when the actual fields are longer than the specified field length. When the actual fields are shorter than the specified field length, the actual field length is processed.
To specify an unsigned binary number for typ, specify mask value for len in decimal number. The logical products of the field value and mask value are considered to be the key value.

Note

The length of the key field does not contain double quotation marks (") that enclose the field for text file CSV format and text file TSV format. When two consecutive double quotation marks ("") are included in the field, they are interpreted as one double quotation mark (").

Example: Key field and length in text file CSV format.
Key field        Characters effective as key field        Length of key field
ABC              ABC                                      3bytes
"ABC"            ABC                                      3bytes
"A""B""C"        A"B"C                                    5bytes
"A,B,C"          A,B,C                                    5bytes

typ

This specifies the data format of the key field.
For more information, refer to the Data formats that can be specified in the key field.

opt

This specifies operation of the key field.
To specify two or more operations, describe them successively. "a", "r", and "w" can be specified for binary files. All the operations can be specified for the text file. When both "a" and "r" are omitted, it operates assuming that "a" is specified. The operations that can be specified are shown below.

opt

Meaning

a

It sorts data in ascending order. It is in the exclusive relationship with "r".

b

Blanks and tabs in the head of the key field are disregarded.

d

Only the blank and the alphanumeric character are compared.

i

Control character codes are disregarded.

j

Lowercase letters are compared as uppercase letters.

n

Character strings of the numbers that contains signs are compared with arithmetic value. It can be specified only for text files. The result is not guaranteed when characters other than the numbers exist in the character string. When the data format is ASCII code, EBCDIC code or Unicode, it can be specified. It is in the exclusive relationship with "N" and "w".

N

Connected data of alphabet and numbers (for instance, data123 ) are evaluated and sorted separately for the alphabet and the numerical value. After only alphabets are targeted for the comparison and compared, character strings exclusively with numbers are compared with arithmetic value. Data is evaluated from the left of the specified field, and the data that appeared after effective data is disregarded. It can be specified when the data format is ASCII code, EBCDIC code or Unicode. It is in the exclusive relationship with "n" and "w".

r

It sorts the data in descending order. It is in the exclusive relationship with "a".

w

Even if there are consecutive multi-byte characters, each character is compared. Only when the data format is ASCII code, Shift JIS code or Unicode and the Input code system (-q) is ASCII code system or Unicode system, this option can be specified. It is in the exclusive relationship with "n" and "N".

Note

  • When modify collation sequence is specified for a data form of the key field, the operations other than "a" or "r" cannot be specified.

  • When character form two digit years, packed decimal form two digit years, external decimal form two digit years and decimal form two digit years are specified for a data form of the key field, the operations other than "a" or "r" are disregarded.

Example

  1. To specify to sort the fields of ASCII code in 10 bytes length from the head of the record in ascending order:

    -0.10asca
  2. To specify an external decimal number in 8 bytes length from the 5th byte of the input record, arranged in descending order:

    -4.8zdlr
  3. To specify ASCII code in 20 bytes length, arranged from the 10th byte of the input record in ascending order at the text file fixed field specification:

    -9.20ascabj

    The first blank and tab of the key field are disregarded, and lower case letters are treated as upper case letters.


Information

For the binary file variable-length record form or the text file, when the record where the key field does not exist is input, the value of the part where the key field does not exist is processed as 0.

Example 1) binary file variable-length record form or the text file fixed field:

key field:6.4asca

  0123456789 : Record where key field exists
  012345     : Record where key field doesn't exist

Example 2) the text file floating field, the text file CSV format or the text file TSV format:

key field:2.1asca

  fld0,fld1,fld2,fld3 : Record where key field exists
  fld0,fld1           : Record where key field doesn't exist
  fld0,fld1,,fld3     : Record where key field doesn't exist