Hello everyone,
I have several columns:
1- “start date” columns
2- “End date” columns
Normally, each column belonging to group (2) should also belong to group (1) and vice versa. So we should have the same number of columns in both groups.
However, columns belonging to group 1 do not belong to group 2 and vice versa.
Example : "start date 9899" but the column "end date 9899" does not exist.
The objective is to have the intersection of these 2 groups so that there are the same columns in the 2 groups.
I am inspired by the following code:Names Default To Here(1);
dt = Current Data Table();
// build
aa_duree = Associative Array();
aa_nonduree = Associative Array();
For Each({col_name}, dt << Get Column Names("String"),
If(Word(1, col_name) == "date début",
aa_duree[Word(-1, col_name)] = col_name;
, !IsMissing(Regex(col_name, "")),
aa_nonduree[col_name] = 1;
,
continue()
);
);
show(aa_duree);
show(aa_nonduree);
aa_duree_copy = aa_duree;
aa_duree_copy << Intersect(aa_nonduree);
cols_to_keep = Insert(aa_duree_copy << get keys, aa_duree_copy << get values);
aa_duree_copy2 = aa_duree;
aa_nonduree_copy = aa_nonduree;
aa_duree_copy2 << remove(aa_nonduree);
aa_nonduree_copy << remove(aa_duree);
cols_to_remove = Insert(aa_nonduree_copy << get keys, aa_duree_copy2 << get values);
show(cols_to_keep, cols_to_remove);