(Video materials in preparation)
makec : Converts row data into columns.
Usage : makec [-<n>] [-d<str>] <file>
makec [-<n>] [-d<str>] num=<n> <file>
Version : Thu May 25 13:12:38 JST 2017
Edition : 2
Reorgaizes data by creating separate records from a single record using
as a key the first field up until the field specified as "num=<n>".
(Original Data:data)
$ cat data
0000000 Smith______ 50 F 91 59 20 76
0000001 Jones______ 50 F 46 39 8 5
0000003 Wilson_____ 26 F 30 50 71 36
0000004 Drake______ 40 M 58 71 20 10
$ makec num=4 data <- The key is fields 1 to 4
0000000 Smith______ 50 F 91
0000000 Smith______ 50 F 59
0000000 Smith______ 50 F 20
0000000 Smith______ 50 F 76
0000001 Jones______ 50 F 46
0000001 Jones______ 50 F 39
0000001 Jones______ 50 F 8
0000001 Jones______ 50 F 5
0000003 Wilson_____ 26 F 30
0000003 Wilson_____ 26 F 50
0000003 Wilson_____ 26 F 71
0000003 Wilson_____ 26 F 36
0000004 Drake______ 40 M 58
0000004 Drake______ 40 M 71
0000004 Drake______ 40 M 20
0000004 Drake______ 40 M 10
Use the -<n> option to specify how many non-key fields are grouped
into a single record.
$ makec -2 num=4 data <- A new record is created every 2 fields
0000000 Smith______ 50 F 91 59
0000000 Smith______ 50 F 20 76
0000001 Jones______ 50 F 46 39
0000001 Jones______ 50 F 8 5
0000003 Wilson_____ 26 F 30 50
0000003 Wilson_____ 26 F 71 36
0000004 Drake______ 40 M 58 71
0000004 Drake______ 40 M 20 10
If num=<n> is not specified, then the data is converted into a list
of records with a single field.
$ cat data3
1 2 3 4
5 6
$ makec data3
1
2
3
4
5
6
The -d<str> option specifies the field separator. The key fields
specified with num=<n> must be separated by whitespace.
$ cat data
0000000 Smith______ 50 F 91@59@20@76@54
0000001 Jones______ 50 F 46@39@8@5@21
0000003 Wilson_____ 26 F 30@50@71@36@30
0000004 Drake______ 40 M 58@71@20@10@6
$ makec -d@ num=4 data4
0000000 Smith______ 50 F 91
0000000 Smith______ 50 F 59
0000000 Smith______ 50 F 20
0000000 Smith______ 50 F 76
0000000 Smith______ 50 F 54
0000001 Jones______ 50 F 46
0000001 Jones______ 50 F 39
0000001 Jones______ 50 F 8
0000001 Jones______ 50 F 5
0000001 Jones______ 50 F 21
0000003 Wilson_____ 26 F 30
0000003 Wilson_____ 26 F 50
0000003 Wilson_____ 26 F 71
0000003 Wilson_____ 26 F 36
0000003 Wilson_____ 26 F 30
0000004 Drake______ 40 M 58
0000004 Drake______ 40 M 71
0000004 Drake______ 40 M 20
0000004 Drake______ 40 M 10
0000004 Drake______ 40 M 6
$ cat data5
0001 1\n2\n3
0002 4\n5\n6
$ makec -d'\n' num=1 data5
0001 1
0001 2
0001 3
0002 4
0002 5
0002 6
If The -d<str> option without <str> specifies 1 field with <n>
characters where <n> is specified by -<n> option. In ths case, space
has no special meaning and counted 1 character.
$ cat data6
0001 abcd efgh ijkl
0002 AB CDEFG HI
$ makec -4 -d num=1 data6
0001 abcd
0001 efg
0001 h ij
0001 kl
0002 AB C
0002 DEFG
0002 HI