如何使用“文字到列”方法,但隨後不手動重命名所有拆分的列?
你好,
有幾種方法可以做到這一點。
腳本:
Names Default To Here(1);
dt = open("ExTable.jmp");
//find column position of column to be split
columnPosition = contains(dt << get column names(string), "CombinedFields");
//determine original number of columns
originalNumCols = ncol(dt);
//new names here...
newColNames = {"Model", "Country", "Type"};
//split the column
dt << Text to Columns( columns( :CombinedFields ), Delimiters( "," ) );
//how many new columns are there?
numColsCreated = ncol(dt) - originalNumCols;
//loop through the new columns, using original column's position as an offset, and change names
for(i = 1, i<=numColsCreated, i++,
column(dt, columnPosition + i) << set name(newColNames[i])
);
剪切和粘貼:
將新的列名放在表格的單個列中,將它們全部選中,然後使用 CTRL-C(Mac 上為 CMD-C)複製它們。

執行 Text To Columns 操作,然後選擇新列並按 CTRL-V 粘貼新名稱。


使用重新編碼列名
首先,使用 Text To Columns 拆分感興趣的列。
下一個,選擇列 > 列名 > 重新編碼列名...從主菜單。

根據需要輸入新的列名稱,然後單擊重新編碼按鈕完成。

附表和腳本。
乾杯,
布雷迪