JSL:如何按共同的初始术语对所有列进行分组?我有一个 dt(70k cols),我想根据最初描述的术语将其分组为通用捆绑包。
例如,每个 10K 列均以“ChamberID”、“RecipeID”或“SlotNo”开头。
我怎样才能编写这个脚本来通过 dt 来查找所有常见的列,并将它们分组到一个可折叠的包中?

自动化和脚本编写回复:JSL:如何按共同的初始术语对所有列进行分组?这是一个小脚本,是在数据表中创建列组的示例。

Names Default To Here( 1 );
dt =
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
colNames = dt << get column names( string, continuous );
group1 = {};
group2 = {};
For Each( {name}, colNames,
/*If(
Left( name, 9 ) == "ChamberID",
Insert Into( group1, name ),
Left( name, 8 ) == "RecipeID",
Insert Into( group2, name )
)*/
If(
Left( name, 3 ) == "NPN",
Insert Into( group1, name ),
Left( name, 3 ) == "PNP",
Insert Into( group2, name )
)
);
dt << group columns( "NPN", group1);
dt << group columns( "PNP", group2);回复:JSL:如何按共同的初始术语对所有列进行分组?有很多方法可以做到这一点。 我使用了与下面脚本中演示的类似的东西(使用关联数组)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
aa_groups = ["DELL" => {}, "DELW" => {}, "RCON" => {}];
col_names = dt << Get Column Names("String");
For Each({col_name}, col_names,
For Each({{key, value}}, aa_groups,
If(Starts With(col_name, key ||"_"), // "_" is used as additional separator
Insert Into(aa_groups[key], col_name);
Break();
)
);
);
For Each({{groupname, groupcols}}, aa_groups,
dt << Group Columns(groupname, groupcols);
);
如果你需要更有活力,你也可以这样做
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
aa_groups = Associative Array();
col_names = dt << Get Column Names("String");
For Each({col_name}, col_names,
nameparts = Words(col_name, "_"); // depending ion your columns, this might need to change
If(N Items(nameparts) > 1,
If(!Contains(aa_groups, nameparts[1]),
aa_groups[nameparts[1]] = {}; // add new key
);
Insert Into(aa_groups[nameparts[1]], col_name);
);
);
For Each({{groupname, groupcols}}, aa_groups,
dt << Group Columns(groupname, groupcols);
);
两者的想法是相同的。 创建关联数组,其中键是列组名称,值是属于该组的列的列表。