JSL: come raggruppare tutte le colonne in base al termine iniziale comune?Ho un dt (70k colonne) che vorrei raggruppare in pacchetti comuni, in base ai termini delineati iniziali.
Ad esempio, colonne da 10.000 ciascuna che iniziano tutte con "ChamberID" o "RecipeID" o "SlotNo".
Come posso scrivere questo script per sfogliare il dt per trovare tutti i col comuni, raggrupparli in un pacchetto pieghevole?

Automazione e scriptingRi: JSL: come raggruppare tutte le colonne in base al termine iniziale comune?Ecco un piccolo script che è un esempio di creazione di gruppi di colonne in una tabella di dati.

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);Ri: JSL: come raggruppare tutte le colonne in base al termine iniziale comune?Ci sono molti modi per farlo. Ho usato qualcosa di simile come dimostro nello script seguente (usando l'array associativo)
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);
);
Se hai bisogno di diventare più dinamico, puoi farlo anche tu
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);
);
L'idea è la stessa in entrambi. Crea un array associativo in cui le chiavi sono nomi di gruppi di colonne e i valori sono elenchi di colonne che appartengono a quel gruppo.