Replace vector data with corresponding taxonomy character in the reference file joined by key. Table 3.43 shows items in a vector with sequential elements separated by a space.
The examples are highlighted in Table 3.43 - 3.44.
Table 3.43: Input data in.csv |
||||||||||
no items 1 a b c 2 a d 3 b f e f 4 f c d |
item |
taxo |
a |
X |
b |
Y |
c |
Z |
e |
X |
f |
Z |
Table 3.44: Basic example vf=items m=ref.csv K=item f=taxo |
||||||||||
no items 1 X Y Z 2 X d 3 Y Z X Z 4 Z Z d |
no |
items |
1 |
X Y Z |
2 |
X * |
3 |
Y Z X Z |
4 |
Z Z * |
Since the mvreplace command reads the whole reference file at once in memory, note that huge reference file may consume massive amount of memory, .
mvreplace vf= K= f= [n=] m=| i= [o=] [delim=] [-nfn] [-nfno] [-x] [--help] [--version]
vf= Specify the field name of vector (from input file i=). Multiple fields can be specified. Sorting on vectors is not required. m= Reference file K= Key field in reference file (m=) where corresponding taxonomy elements are joined with vector items. The sequence of the vector is unique, sorting is not required. The output may differ if the string sequence is not unique. f= Field name of vector for joining. n= Specify the replacement character when the elements that do not match in vf= and K= . The element will not be joined with the reference file when this option not specified.
$ more dat1.csv items b a c c c e a a $ more ref1.csv item,taxo a,X Y b,X c,Z Z $ mvreplace vf=items K=item m=ref1.csv f=taxo i=dat1.csv o=rsl1.csv #END# kgVreplace K=item f=taxo i=dat1.csv m=ref1.csv o=rsl1.csv vf=items $ more rsl1.csv items X X Y Z Z Z Z Z Z e X Y X Y
$ more dat2.csv items1,items2 b a c,b b c c,a d e a a,a a $ more ref2.csv item,taxo a,X b,X c,Y d,Y $ mvreplace vf=items1,items2 K=item m=ref2.csv f=taxo i=dat2.csv o=rsl2.csv #END# kgVreplace K=item f=taxo i=dat2.csv m=ref2.csv o=rsl2.csv vf=items1,items2 $ more rsl2.csv items1,items2 X X Y,X X Y Y,X Y e X X,X X
mvjoin : Use mvjoin to combine the elements instead of replacing elements.