Your code is basically close to perfect. According to my test results, the problem as described below still exists.
(1). Taking kLG_ 12.data
as an example, as you can see, there are so many Null in the first line:
{
{C2, Null, Null, Null, "", Null, Null, "", 6},
{0, 0, 0.5, 1, "A1", 1, 8, "A", 1},
{0, 0, 0.5, 1, "A1-", 1, 8, "A", 1},
{0, 0, 0.5, 1, "A2", 1, 8, "A", 1},
{0, 0, 0.5, 1, "A2-", 1, 8, "A", 1},
{0, 0, 0.5, 1, "-A3", 1, 8, "A", 0},
{0, 0, 0.5, 1, "-A4", 1, 8, "A", 0},
{0, 0, 0.5, 1, "-A5", 1, 8, "A", 0},
{0, 0, 0.5, 1, "-A6", 1, 8, "A", 0},
{0, 0, 0, 1, "GM1", 1, 8, "GM", 1},
{0, 0, 0, 1, "GM1-", 1, 8, "GM", 1},
{0, 0, 0, 1, "GM2", 1, 8, "GM", 1},
{0, 0, 0, 1, "GM2-", 1, 8, "GM", 1},
{0, 0, 0, 1, "-GM3", 1, 8, "GM", 0},
{0, 0, 0, 1, "-GM4", 1, 8, "GM", 0},
{0, 0, 0, 1, "-GM5", 1, 8, "GM", 0},
{0, 0, 0, 1, "-GM6", 1, 8, "GM", 0},
{0, 1, 0.5, 1, "M1", 1, 8, "M", 1},
{0, 1, 0.5, 1, "M1-", 1, 8, "M", 1},
{0, 1, 0.5, 1, "M2", 1, 8, "M", 1},
{0, 1, 0.5, 1, "M2-", 1, 8, "M", 1},
{0, 1, 0.5, 1, "-M3", 1, 8, "M", 0},
{0, 1, 0.5, 1, "-M4", 1, 8, "M", 0},
{0, 1, 0.5, 1, "-M5", 1, 8, "M", 0},
{0, 1, 0.5, 1, "-M6", 1, 8, "M", 0},
{0, 1, 0, 1, "Y1", 1, 8, "Y", 1},
{0, 1, 0, 1, "Y1-", 1, 8, "Y", 1},
{0, 1, 0, 1, "Y2", 1, 8, "Y", 1},
{0, 1, 0, 1, "Y2-", 1, 8, "Y", 1},
{0, 1, 0, 1, "-Y3", 1, 8, "Y", 0},
{0, 1, 0, 1, "-Y4", 1, 8, "Y", 0},
{0, 1, 0, 1, "-Y5", 1, 8, "Y", 0},
{0, 1, 0, 1, "-Y6", 1, 8, "Y", 0},
{0.123, 0, 0.427, 1, "B1", 1, 4, "B", 1},
{0.123, 0, 0.427, 1, "B2", 1, 4, "B", 1},
{0.123, 0, 0.427, 1, "-B3", 1, 4, "B", 0},
{0.123, 0, 0.427, 1, "-B4", 1, 4, "B", 0},
{0.5, 0.5, 0.5, 1, "L1", 1, 4, "L", 1},
{0.5, 0.5, 0.5, 1, "L1-", 1, 4, "L", 1},
{0.5, 0.5, 0.5, 1, "-L2", 1, 4, "L", 1},
{0.5, 0.5, 0.5, 1, "-L3", 1, 4, "L", 1},
{0, 0.313, 0, 1, "LD1", 1, 4, "LD", 1},
{0, 0.313, 0, 1, "LD2", 1, 4, "LD", 1},
{0, 0.313, 0, 1, "-LD3", 1, 4, "LD", 0},
{0, 0.313, 0, 1, "-LD4", 1, 4, "LD", 0},
{0, 0.313, 0.5, 1, "U1", 1, 4, "U", 1},
{0, 0.313, 0.5, 1, "U2", 1, 4, "U", 1},
{0, 0.313, 0.5, 1, "-U3", 1, 4, "U", 0},
{0, 0.313, 0.5, 1, "-U4", 1, 4, "U", 0},
{0.5, 0.5, 0, 1, "V1", 1, 4, "V", 1},
{0.5, 0.5, 0, 1, "V1-", 1, 4, "V", 1},
{0.5, 0.5, 0, 1, "-V2", 1, 4, "V", 1},
{0.5, 0.5, 0, 1, "-V3", 1, 4, "V", 1},
{0.123, 0.313, 0.427, 1, "GP1", 1, 2, "GP", 1},
{0.123, 0.313, 0.427, 1, "-GP2", 1, 2, "GP", 1},
{0.123, 0.313, 0.427, 1, "-GP2", 1, 2, "GP", 1}
}
(2) The last two lines are the same, which is why I use awk '!a[$0]++' in my solution.
(3) Your code will remove the "+" symbol in the output, for example, the following one:
0.5 0.5 0 1 V1+ 1 4 V 1
will be displayed as the following error result:
0.5 0.5 0 1 V1 1 4 V 1
Regards,
HZ