xtaccum
Section: User Commands (1)
Updated: 2002-10-26
Index
Return to Main Contents
NAME
xtaccum - calculate the cumulative value
SYNOPSIS
xtaccum
[-k attritute] [-s attributes to be sorted[%{n|r}]] -f attritute list [-i INPUT] [-o OUTPUT] [-z] [-t] [-T TEMP DIRECTORY]
DESCRIPTION
This command calculates the cumulative values for the field argument based on the sequence of the key attribute(s).
A user has to specify the key attribute -k for the basis of calculatng the cumulative value for each key record, and the field in option -f where the calculations will be performed.
If -k is not specified, the calculation will be based upon all records in the data. The calculated value will be stored as a new attribute appended to the last column of the data, the name of the new attribute should be specified by '-f attribute name:A'.
As an important precaution, xtaccum does not automatically sort the input file by the key argument, therefore, the input file needs to be sorted by xtsort before proceeding with the calculation.
PARAMETERS
- -k key attritute
-
the key attribute for which the calculated values are based on.
- -s sort attributes
-
sort order of cumulative values for records with the same key values.
- -f attritute
-
attribute(s) for which the cumulative value is calculated.
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.
- -T temp file directory
-
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
-
treat 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>Amount</name>
</field>
</header>
<body><![CDATA[
A00005 20020918 1504
A00005 20020918 1875
A00005 20020918 365
A00005 20020918 810
A00005 20020923 491
A00033 20020618 1389
A00033 20020618 1656
A00033 20020618 183
A00033 20020618 305
A00033 20020618 501
A00033 20020618 576
A00052 20020216 249
A00052 20020216 357
A00052 20020216 446
A00053 20020106 233
A00053 20020106 586
A00053 20020208 429
A00053 20020427 2004
A00053 20020427 362
A00053 20020427 435
]]></body>
</xmltbl>
Example 1. Calculate the cumulative value of the amount purchased by the customer over their visits.
e.g. xtaccum -k CustomerID -s Date -f Amount:Total -i dat.xt -o rsl.xt
Output file - rsl.xt
-
<field no="1">
<name>CustomerID</name>
</field>
<field no="2">
<name>Date</name>
</field>
<field no="3">
<name>Amount</name>
</field>
<field no="4">
<name>Total</name>
</field>
</header>
<body><![CDATA[
A00005 20020918 1504 1504
A00005 20020918 1875 3379
A00005 20020918 365 3744
A00005 20020918 810 4554
A00005 20020923 491 5045
A00033 20020618 1389 1389
A00033 20020618 1656 3045
A00033 20020618 183 3228
A00033 20020618 305 3533
A00033 20020618 501 4034
A00033 20020618 576 4610
A00052 20020216 249 249
A00052 20020216 357 606
A00052 20020216 446 1052
A00053 20020106 233 233
A00053 20020106 586 819
A00053 20020208 429 1248
A00053 20020427 2004 3252
A00053 20020427 362 3614
A00053 20020427 435 4049
]]></body>
</xmltbl>
Example 2. Calculate the cumulative value all purchases over time.
e.g. xtaccum -s date -f amount:total -i dat.xt -o rsl.xt
Output file - rsl.xt
-
A00053 20020106 233 233
A00053 20020106 586 819
A00131 20020108 1180 1999
A00131 20020108 1224 3223
A00131 20020108 228 3451
A00131 20020108 356 3807
B00080 20020113 1053 4860
B00080 20020113 276 5136
B00080 20020113 361 5497
B00080 20020113 456 5953
B00080 20020113 645 6598
D00241 20020117 75 6673
C00215 20020118 165 6838
C00215 20020118 349 7187
C00215 20020118 357 7544
C00215 20020118 617 8161
D00131 20020128 323 8484
D00131 20020128 380 8864
D00131 20020128 920 9784
DIAGNOSTICS
The xtaccum can only be applied to numeric fields.
Be sure the data is sorted by key prior to xtaccum.
If there happens to be a null value in any of the values, the cumulative value will be null.
To avoid this, delete the line with null value with "xtdelnul" command, or replace the null value to 0 by "xtnulto" command.
An input must be specified at the first command or the program will halt until an input is specified. To exit, simply hold down the ctrl key and press c.
SEE ALSO
xtagg(1),
xtstatistics(1),
xtshare(1)
For complete documentation and tutorial of xtaccum and other commands, please visit
http://musashien.sourceforge.net.
BUG REPORT
If you find a bug in xtaccum, 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