Ho rielaborato il copione precedente per soddisfare le tue nuove esigenze.
Names Default To Here( 1 );
dt = Current Data Table();
keep = {};
delete = {};
colNameList = dt << get column names( string );
numericNamesOnly = colNameList;
For( i = N Items( colNameList ), i >= 1, i--,
colNameList[i] = Uppercase( colNameList[i] );
If( Is Missing( Num( colNameList[i] ) ) == 1,
numericNamesOnly[i] = ""
);
);
While( N Items( colNameList ) > 0,
If(
Contains( colNameList[1], Uppercase( "Date début" ) ),
found = Contains( numericNamesOnly, Word( 3, colNameList[1] ) );
If( found > 0,
Insert Into( keep, colNameList[1] );
Insert Into( keep, numericNamesOnly[found] );
Remove From( numericNamesOnly, found, 1 );
Remove From( numericNamesOnly, 1, 1 );
Remove From( colNameList, found, 1 );
Remove From( colNameList, 1, 1 );
,
Insert Into( delete, colNameList[1] );
Remove From( colNameList, 1, 1 );
Remove From( numericNamesOnly, 1, 1 );
);,
Is Missing( Num( colNameList[1] ) ) == 0,
found = Contains( colNameList, Uppercase( "DATE début " ) || colNameList[1] );
If( found > 0,
Insert Into( keep, colNameList[1] );
Insert Into( keep, dateDebutOnly[found] );
Remove From( numericNamesOnly, found, 1 );
Remove From( numericNamesOnly, 1, 1 );
Remove From( colNameList, found, 1 );
Remove From( colNameList, 1, 1 );
,
Insert Into( delete, colNameList[1] );
Remove From( colNameList, 1, 1 );
Remove From( numericNamesOnly, 1, 1 );
);,
Remove From( colNameList, 1, 1 );
Remove From( numericNamesOnly, 1, 1 );
)
);
dt << delete columns(delete);
Non è un bel codice, ma mostra il modo diretto per portare a termine il lavoro.
Nota: hai un errore nella tabella dei dati di esempio.Hai un nome di colonna "Datd début 952" che deve essere modificato in "Date début 952"
Grazie funziona!
Ho provato ad usare il tuo script ma inizialmente non sapevo come caratterizzare tutte le colonne del secondo gruppo perché non ci sono termini simili.
Salve a tutti, ho una tabella dati simile a questa:
Il database è composto da 2 gruppi:
- Le date ("data di inizio...")
- Numeri associati alle operazioni
Il mio obiettivo è rimuovere le colonne che non si trovano nell'intersezione dei due gruppi di colonne.
Vale a dire qui, vorrei cancellare automaticamente con uno script le colonne: "Data inizio 952", "9950"
Grazie per l'aiuto !
Grazie per aver salvato anche la mia giornata. 