68user's page 掲示板

Prev< No. 4584> Next  [最新発言に戻る] [過去ログ一覧]
No. 4584 # べた 2006/04/19 (水) 22:45:43
>>4582 zsh
>>4583 べた

一応、動きます。
以下のようになるのでしょうか。

BEGIN{
        FS=",";
        chk_col=11;
}
{
        str_head_1=$1;
        split_num=chk_comma_max(NF);
        if(split_num!=0) {
                str_head_2=head_string(chk_col);
                split($chk_col, str_foot, ":");
                for (i=1; i<=split_num; i++) {
                        for (j=chk_col+1; j<=NF; j++) {
                                split($j, col_buf, ":");
                                str_foot[i]=sprintf("%s,%s", str_foot[i], col_buf[i]);
                        }
                        print str_head_1 "," i "," str_head_2 "," str_foot[i];
                }
        } else {
                str_head_2=head_string(NF+1);
                print str_head_1 ",1," str_head_2;
        }
}
function chk_comma_max(chk_point) {
        comma_num=0;
        for (k=chk_col; k<=chk_point; k++) {
                if($k ~ /:/) {
                        comma_num=split($k, s, ":");
                        break;
                }
        }
        return comma_num;
}
function head_string(chk_point) {
        str_buf=$3;
        for (k=4; k<chk_point; k++) {
                str_buf=sprintf("%s,%s", str_buf, $k);
        }
        return str_buf;
}

Prev< No. 4584> Next  [最新発言に戻る] [過去ログ一覧]