Collate

PURPOSE   OPERATION   COMMAND LINES   PARAMETER FILE   OPTIONS   RELATED PROGRAMS


Author: Dan Mares, dmares @ maresware . com (you will be asked for e-mail address confirmation)
Portions Copyright © 1998-2021 by Dan Mares and Mares and Company, LLC
Phone: 678-427-3275

One liner: collate will merge/combine two files sorted on the same key field..

All programs are command line programs.
MUST be run within a command window as administrator.


top

Purpose

The files must be of the same record layout.


top

Operation

This program will take two identically formatted files that are sorted and collate them together into one output file.

The files can be sorted in either ascending or descending order.

The files must be of a fixed record length, but do not need to have carriage returns as a record terminator.


top

Command Line

C:>collate input.1 input.2 output -r # -p # -l # -1 10000 -2 10000 -d

Item 1:  Program name [collate]
Item 2:  Input file no. 1
Item 3:  Input file no. 2
Item 4:  Output file
Item 5-7: Are paired options with integers to designate record length, key displacement and length, and output blocksize.

The first item of the pair is an option: either [-r or -p or -l ] indicating the next argument is either record length, displacement, length of key field.

If you use a parameter file, then none of the Item 5 items need be used. If you use a parameter file and also choose to use the command line options, the command line options override whatever sizes are found in the parameter file.

The options can be included in any order, but the number following the option must reflect that option's value.

Item 8-9:  option -1 or -2 + integer indicating input blocksize or either the #1 or #2 input file. Both should be used. However, the program will default.
Item 10:  option[-d or -a]

-d == file is sorted in descending order
-a == file is sorted in ascending order

SAMPLE COMMAND LINES:

C:>collate   in1   in2   out   -r   200   -p   20   -l   3   -1   2000   -2   4000

record length (-r) == 200
position(-p) to key is 20 beginning at zero
keylength (-l) is 3
and a default of ascending sort is used
input A (-1) has a blocksize of 2000
input B (-2) has a blocksize of 4000.

C:>collate   in1   in2   out   -p   20   -l   3   -r   200   -a

Same as above, except -a (ascending) option is explicitly stated. Notice that order of [rpl] is not important

C:>collate in1 in2 out -r 200 -p 0 -l 20 -d

Record length ==200
position to key==0(first character of record)
key length ==20
and descending sort order is indicated.


top

Parameter file

The parameter file is optional and is used to replace the command line options for repetitive collates. The format of the parameter file is one item per line in the following order:

Item 1:  Input file A blocksize
Item 2:  Input file B blocksize
Item 3:  Input file record length.
Item 4:  Displacement to key field
Item 5:  Length of key field


top

Options

-A   Create/append accounting file

-a   Indicates the file is sorted in ascending order (default is ascending)

-d   Indicates the file is sorted in descending order

-r +#   Record length of file

-p +#   Position (from 0) to sorted field

-l +#   Length of field


Related Programs

Compare

Disksort

top