xtbest

Section: User Commands (1)
Updated: 2002-10-26
Index Return to Main Contents

 

NAME

xtbest - selection of best records

 

SYNOPSIS

xtbest -R range of / individual records [-k key attribute] [-s attribute(s) whose value will be sorted upon with records having the same key value[%{n|r}]] [-r] [-u EXCEPTION OUTPUT] [-q] [-i INPUT] [-o OUTPUT] [-z] [-t] [-T TEMP DIRECTORY]

 

DESCRIPTION

This command selects the preceding records in order from the data set with respect to the key attribute -k as the unit for selection, the number of records to be returned is defined by the parameter -R. If -k is not specified, the selection will be based upon all records in the data. Data must be sorted by the key attribute with xtsort prior to xtbest command in order for the ranking to be listed correctly.

 

PARAMETERS

-k key attribute(s)
key attribute(s) which enumeration is performed. Multiple key attributes can be defined by "- k key1,key2". When -k is omitted, all records will be based on one key unit.
-s sorting on attribute
records will be sorted on the attribute specified by -s with the same key value
The specification of selecting records by range -R are as follows:

  (1) -R 5: select the top five records 

  (2) -R _5: select the five best records which tops out on all data 

  (3) -R MIN_5 : same as "-R _5"          

  (4) -R 5_MAX : select the fifth to the last record 

  (5) -R 2_5:  select the second to the fifth record        

  (6) -R 1,5_MAX: select the first record and the fifth to the last record. 


When the range specified by -R is exceed the actual records, only the records existed in data will be selected.

-r reverse selection
reverse the selection specified by -R. e.g., '-r -R 1' selects all records except the best one.
-q sequential processing
When this option is used with the -k parameter, the command processes the input data in original sequence of the lines, instead of sorting by the key attribute -k.

 

FILE OPTIONS

-i input filename
if a suffix of the filename is '.gz', the command acts as a filter, extracting the compressed file for processing. The command will read the file as standard input when "-i" is not specified.
-o output filename
if a suffix of the filename is '.gz', the command automatically returns the output data in zip archive. When "-o" is not specified, the result will sent to standard output.
-u output filename for data excluded
allows records secluded from the condition specified by -R to be saved in the file defined by the option -u.
-T temp file directory
specify the directory name for temporal files used in this command.
-z zip archive
compress the standard output to zip archive. When the option "-o" is not given and "-z" is specified, the output will be compressed as zip archive.
-t plain text
xtagg treats the input and output data as plain text format.

 

USAGE

Input file - dat.xt:
<field no="1">
<name>CustomerID</name>
</field>
<field no="2">
<name>Date</name>
</field>
<field no="3">
<name>TotalQuantity</name>
</field>
<field no="4">
<name>TotalAmount</name>
</field>
</header>
<body><![CDATA[
A00001 20020826 5 2090
A00001 20021221 8 3038
A00002 20020112 1 341
A00002 20020208 12 4812
A00002 20020726 9 3379
A00002 20020822 10 4013
A00002 20021225 9 3532
A00003 20020727 8 1983
A00003 20020813 9 2898
A00003 20021008 11 4110
A00004 20020214 1 365
A00004 20020415 9 4349
A00004 20020625 13 5268
A00004 20020810 5 1805
A00004 20021014 2 612
A00004 20021016 11 3410

Example 1. Select the 10th the record in the data.
e.g. xtbest -R 10 -i dat.xt -o rsl.xt Output: -rsl.xt


<body><![CDATA[
A00003 20021008 11 4110
]]></body>

Example 2. Select the 5th to 15th customer on the record.
e.g. xtbest -R 5_15 -i dat.xt -o rsl.xt Output: -rsl.xt


<body><![CDATA[
A00002 20020726 9 3379
A00002 20020822 10 4013
A00002 20021225 9 3532
A00003 20020727 8 1983
A00003 20020813 9 2898
A00003 20021008 11 4110
A00004 20020214 1 365
A00004 20020415 9 4349
A00004 20020625 13 5268
A00004 20020810 5 1805
A00004 20021014 2 612
]]></body>

Example 3. Select the top 3 customers with highest total amount for each date.
e.g. xtbest -k Date -R 1,2,3 -s TotalAmount%n%r -i dat.xt -o rsl.xt Output: -rsl.xt


<body><![CDATA[
A00021 20020101 24 8496
A00082 20020101 19 6913
C00052 20020101 15 6197
A00256 20020102 12 4561
A00235 20020102 15 4470
C00152 20020102 12 4271
A00257 20020103 24 11494
A00230 20020103 21 8401
C00046 20020103 18 7819
A00251 20020104 12 6220
D00016 20020104 15 5779
C00238 20020104 13 4698

Example 4. Select the first 5 records and from the 600th record to last record .
e.g. xtbest -R MIN_5,600_MAX -i dat.xt -o rsl.xt Output: -rsl.xt


<body><![CDATA[
A00001 20020826 5 2090
A00001 20021221 8 3038
A00002 20020112 1 341
A00002 20020208 12 4812
A00002 20020726 9 3379
A00117 20021021 4 1267
A00117 20021028 2 872
A00117 20021111 11 3847
A00117 20021126 15 3983
A00117 20021222 5 2034
A00118 20020130 4 1872
A00118 20020512 10 3449
A00118 20020514 9 2949
A00118 20020522 5 1617
A00118 20020620 9 3534
A00118 20020712 8 2927
A00118 20020913 2 517

 

DIAGNOSTICS

A standard file input must be specified at the end or the program will halt until a standard input is specified. To exit, simply hold down the ctrl key and press c. Data must be sorted by key values in order for the records to be ranked in order, and there select the best from the specified range.

 

SEE ALSO

xtsel(1), xtuniq(1) For complete documentation and tutorial of xtbest and other commands, please visit http://musashien.sourceforge.net.

 

BUG REPORT

If you find a bug in xtbest, please send an electronic mail to musashi@adm.osaka-sandai.ac.jp. Before sending a bug report, please verify that you have the lastest version of MUSASHI. Read this manual carefully to ensure the error is not caused by a quirk in the language.

 

AUTHORS

Yukinobu Hamuro, Naoki Katoh, Katsutoshi Yada, Stephane Cheung


 

Index

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS
FILE OPTIONS
USAGE
DIAGNOSTICS
SEE ALSO
BUG REPORT
AUTHORS

This document was created by man2html, using the manual pages.
Time: 22:43:52 GMT, June 24, 2003