(Video materials in preparation)
tagmap : Converts a tag file list to a matrix with row and column headings
Usage : tagmap [-<l>] num=<n>x<m> <file>
tagmap +yarr [-<l>] num=<n>x<m> <file>
Option : -m<str>
-n
Version : Tue Sep 17 13:28:35 JST 2024
Edition : 1
Re-formats the specified file or standard input into a matrix consisting
of <n> row key fields, <m> column key fields (m=1 when omitted)
and the rest of the fields as data fields.
When formatting as a matrix, any missing data is padded with zeroes.
You can change the padding character with the -m option.
$ cat tagdata
Shop Dept Sold Stocked
001 1001 20 60
001 1002 30 70
002 1001 40 80
002 1002 50 90
$ tagmap num=1 tagdata | fcols
Shop * 1001 1002
001 Sold 20 30
001 Stocked 60 70
002 Sold 40 50
002 Stocked 80 90
$ tagmap +yarr num=1 tagdata | fcols
Shop 1001 1001 1002 1002
Shop Sold Stocked Sold Stocked
001 20 60 30 70
002 40 80 50 90
$ cat tagdata2
Shop Dept Class Sold Stocked
001 1001 2001 10 50
001 1001 2002 15 55
001 1002 2001 20 60
001 1002 2002 25 65
002 1001 2001 30 70
002 1001 2002 35 75
002 1002 2001 40 80
002 1002 2002 45 85
$ tagmap num=1x2 tagdata2 | fcols
Shop * 1001 1001 1002 1002
Shop * 2001 2002 2001 2002
001 Sold 10 15 20 25
001 Stocked 50 55 60 65
002 Sold 30 35 40 45
002 Stocked 70 75 80 85
$ tagmap +yarr num=1x2 tagdata2 | fcols
Shop 1001 1001 1001 1001 1002 1002 1002 1002
Shop 2001 2001 2002 2002 2001 2001 2002 2002
Shop Sold Stocked Sold Stocked Sold Stocked Sold Stocked
001 10 50 15 55 20 60 25 65
002 30 70 35 75 40 80 45 85
The -<l> option will create an index.
If you combine with the -n option, the index is numeric.
$ cat tagdata3
Shop Dept Sold1 Stocked1 Sold2 Stocked2
001 1001 20 60 25 65
001 1002 30 70 35 75
002 1001 40 80 45 85
002 1002 50 90 55 95
$ tagmap -2 num=1 tagdata3 | fcols
Shop * 1001 1001 1002 1002
Shop * a b a b
001 Sold1 20 25 30 35
001 Stocked1 60 65 70 75
002 Sold1 40 45 50 55
002 Stocked1 80 85 90 95
$ tagmap -2 -n num=1 tagdata3 | fcols
Shop * 1001 1001 1002 1002
Shop * 1 2 1 2
001 Sold1 20 25 30 35
001 Stocked1 60 65 70 75
002 Sold1 40 45 50 55
002 Stocked1 80 85 90 95
$ tagmap +yarr -2 n num=1 tagdata3 | fcols
Shop * 1001 1001 1002 1002
Shop * Sold1 Stocked1 Sold1 Stocked1
001 A 20 60 30 70
001 B 25 65 35 75
002 A 40 80 50 90
002 B 45 85 55 95
$ tagmap +yarr -2 -n num=1 tagdata3 | fcols
Shop * 1001 1001 1002 1002
Shop * Sold1 Stocked1 Sold1 Stocked1
001 1 20 60 30 70
001 2 25 65 35 75
002 1 40 80 50 90
002 2 45 85 55 95