カンマ区切りのデータを含むクエリの列があります。
読み取り
1,2,3,2,4,3,4,5,2,1,3,4,5,2,1,3,4,2,1,2,3,4,2,1,2, 4、2、3、4、5
各値を解析して列タイトルが D01、D02、D03 などの新しい列を作成するスクリプトが必要です。
この列を操作するために Text to Cols のアドインを使用しましたが、クエリ後のスクリプトの一部としてこれらの列を作成するスクリプトがあれば便利です。
うまくいきました!ありがとう。また、スクリプト内のコメントもありがとうございます。スクリプトを理解し、そこから学ぶのに役立ちます。
再度、感謝します!
実際には、テキストを列に変換()関数。ここでは、列 1 と列 2 の 2 つの列から開始するテーブルでこれを行う方法を示します。 Text to Columns() は分割された列の直後に新しい列を挿入するため、列の位置を決定する必要があります。新しい列がテーブル内のどこにあるかを簡単に見つけて、名前を変更できます。
dt = Current Data Table();
col = "Column 1"; //name of column that needs to be split out
//Need to determine where new columns will go:
colnames = dt << Get Column Names(string);
which_col = Loc(colnames, col)[1]; //get position of column being split
//Get number of columns before split
n_col_pre = N Col(dt);
//Split the column by delimiter
dt << Text to Columns( delimiter(","),
columns(Column(dt, col))
);
//Determine number of new columns
new_cols = N Col(dt) - n_col_pre;
//Rename New Columns
for(i = 1, i <= new_cols, i++,
col_pos = which_col + i; //get position of current column
Column(dt, col_pos) << Set Name("D"||if(i < 10, "0","")||char(i));
Column(dt, col_pos) << Set Data Type(Numeric); //makes each column numeric, not sure if you needed that too
);
前:

後:
