如何使用“文本到列”方法,但随后不手动重命名所有拆分的列?
你好,
有几种方法可以做到这一点。
脚本:
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 拆分感兴趣的列。
下一个,选择列 > 列名 > 重新编码列名...从主菜单。

根据需要输入新的列名称,然后单击重新编码按钮完成。

附表和脚本。
干杯,
布雷迪