새로운 요구 사항을 충족하기 위해 이전 스크립트를 재작업했습니다.
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);
예쁜 코드는 아니지만 작업을 완료하는 직접적인 방법을 보여줍니다.
참고: 샘플 데이터 테이블에 오류가 있습니다."Date début 952"로 변경해야 하는 열 이름 "Datd début 952"가 있습니다.
감사합니다!
귀하의 스크립트를 사용하려고 시도했지만 처음에는 유사한 용어가 없기 때문에 두 번째 그룹의 모든 열을 특성화하는 방법을 몰랐습니다.
안녕하세요 여러분, 다음과 유사한 데이터 테이블이 있습니다.
데이터베이스는 2개의 그룹으로 구성됩니다.
- 날짜("시작일...")
- 작업과 관련된 번호
내 목표는 두 열 그룹의 교차점에 있지 않은 열을 제거하는 것입니다.
즉, 스크립트를 사용하여 "시작 날짜 952", "9950" 열을 자동으로 삭제하고 싶습니다.
당신의 도움을 주셔서 감사합니다 !