1.1 Addition of Automatic Sorting Function

In MCMD Ver. 1.0, sorting by key field with msortf is necessary prior to the aggregate calculation with commands such as msum and joining of files such as mjoin command.

Key fields must be sorted for commands which require specification key field name, or else it would result in calculation error if users failed to sort the key field beforehand, this is the main draw back easily give rise to bugs in scripts.

Therefore, the new function in Ver. 2.0 automatically sorts key columns for commands where key field(s) is/are specified at k= option. The symbol of sort order by column is added to the field name in the CSV header (Refer to sort Sort order of columns for more information), and sorting is only carried out when necessary on required commands.

Example

Example of Ver. 1.0

Before executing msum k=customer command, customer column must be sorted with msortf command.

$ more dat1.csv
customer,amount
A,10
B,10
A,20
B,15
B,20
$ msortf i=dat1.csv f=customer | msum k=customer f=amount:totalamount o=rsl1.csv
#END# kgsortf f=customer i=dat1.csv
#END# kgsum f=amount:totalamount k=customer o=rsl1.csv
$ more rsl1.csv
customer,totalamount
A,30
B,45

Example of Ver. 2.0

msum will perform sorting when necessary without the use of msortf command while achieving the correct results as shown in the previous example. The symbol %0 is added next to the column name of customer after sorting is carried out in msum command.

$ more dat1.csv
customer,amount
A,10
B,10
A,20
B,15
B,20
$ msum i=dat1.csv k=customer f=amount:totalamount o=rsl1.csv
#END# kgsum f=amount:totalamount k=customer i=dat1.csv o=rsl1.csv
$ more rsl1.csv
customer%0,totalamount
A,30
B,45