xtchgnum
Section: User Commands (1)
Updated: 2002-10-26
Index
Return to Main Contents
NAME
xtchgnum - replace numerical values
SYNOPSIS
xtchgnum -f field list -R numerical intervals
[-v new character strings] [-O character string standing for vaules not satisfied by -c] [-F] [-A ] [-r] [-i INPUT] [-o OUTPUT] [-z] [-t]
DESCRIPTION
xtchgnum replaces the numerical value in the attribute specified by -f with character strings defined in the numerical range. Instead of replacing strings in place, the newly defined character string can be stored as a new attribute when the option -A is specified.
Multiple replacement conditions for numerical values can be defined in ranges at option -R, followed by replacement character strings for numerical values that falls in between each range.
Example 1: -R Min,10,30,Max
-
Numerical Ranges with x as the numerical value
x<10
10<=x<30
30<=x
Example 2: -R '10,30'
-
10<=x<30
If the value does not fall into any of the intervals, it will be replaced by a null character *. You may replace null values by other characters with the option -O. Alternatively, the option -F allows the numerial value to be left unchanged if the condition is not satisfied. Option -O and -F cannot be used at the same time.
PARAMETERS
- -f field(s)
-
numerical attributes to be replaced
- -R numerical intervals
-
numerical intervals replacement (1.1_2.5 : at least 1.1 and less than 2.5)
- -v replacement character strings
-
character strings replacing the numerical values falling in between the intervals in the argument -R
- -O character string for values beyond the condition -c
-
Specify character string to be replaced with when the attribute -f does not satisfy the condition -c.
- -F
-
leaves the attribute as the original value when condition -c is not satisfied.
- -A create a new attribute
-
create a new attribute for replacement strings. When -A is not specified, numerical values will be replaced by strings.
- -r change the way of specifying the interval
-
FILE OPTIONS
- -i input filename
-
If a suffix of the filename is '.gz', the command acts as a filter, extracting t
he compressed file for processing. The command will read the file as standard in
put when "-i" is not specified.
- -o output filename
-
If a suffix of the filename is '.gz', the command automatically returns the outp
ut data in zip archive. When "-o" is not specified, the result will sent to stan
dard output.
- -z zip archive
-
compress the standard output to zip archive. When the option "-o" is not given a
nd "-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:
<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
A00005 20020918 12 4554
A00005 20020923 1 491
A00006 20020606 3 1364
A00006 20020918 5 2195
A00007 20020208 1 304
A00007 20020326 6 2618
A00007 20020423 7 2530
A00007 20020426 2 744
A00007 20020605 5 2072
A00007 20021229 11 4375
Example 1. Convert total amount between 0 to 3000->Max, 3001 to 5000-> Med, > 5001 -> Min
e.g. xtchgnum -f TotalAmount -R MIN,3000,5000,MAX -v Min,Med,Max -i dat.xt -o rsl.xt
Output - rsl.xt
-
<body><![CDATA[
A00001 20020826 5 Min
A00001 20021221 8 Med
A00002 20020112 1 Min
A00002 20020208 12 Med
A00002 20020726 9 Med
A00002 20020822 10 Med
A00002 20021225 9 Med
A00003 20020727 8 Min
A00003 20020813 9 Min
A00003 20021008 11 Med
A00004 20020214 1 Min
A00004 20020415 9 Med
A00004 20020625 13 Max
A00004 20020810 5 Min
A00004 20021014 2 Min
A00004 20021016 11 Med
Example 2: Convert the Total Amount between 0 to 2000 -> Min, 2001 to 3000 -> Med, 3001 to 5000 ->Max, and values beyond the ranges as "otheramount"
e.g. xtchgnum -f amount -R 0,5,10,20 -v Max,Med,Min -O other amount -i dat.xt -o rsl.xt
Output - rsl.xt
-
<body><![CDATA[
A00001 20020826 5 Med
A00001 20021221 8 Max
A00002 20020112 1 Min
A00002 20020208 12 Max
A00002 20020726 9 Max
A00002 20020822 10 Max
A00002 20021225 9 Max
A00003 20020727 8 Min
A00003 20020813 9 Med
A00003 20021008 11 Max
A00004 20020214 1 Min
A00004 20020415 9 Max
A00004 20020625 13 otheramount
A00004 20020810 5 Min
DIAGNOSTICS
A standard file input must be specified at the end or the program will halt unti
l a standard input is specified. To exit, simply hold down the ctrl key and pre
ss c.
When the numerical value to be replaced falls out of the defined range -R, it will be replaced by the null character (*).
SEE ALSO
xtchgstr(1),
xtsed(1)
For complete documentation and tutorial of xtchgnum and other commands, please vis it
http://musashien.sourceforge.net.
BUG REPORT
If you find a bug in xtchgnum, 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 l
anguage.
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:53 GMT, June 24, 2003