텍스트를 열로 결과 열내장 JSL Text to Columns() 함수를 사용하고 있습니다. 내 입력 텍스트에 얼마나 많은 "세그먼트"가 있는지 알 수 없으므로 함수 호출로 인해 얼마나 많은 새 열이 생길지 미리 알 수 없습니다. 하지만 내 스크립트에서 특정 후속 단계를 수행하려면 이를 알아야 합니다.
이것이 추가 기능이었을 때 Jeff Perkinson의 v3는 생성된 열의 이름을 제공하는 결과를 반환했습니다. 내장된 버전은 아무 것도 반환하지 않는 것 같습니다(?). 나는 그의 v3를 설치했지만 그의 버전의 기능에 대한 스크립팅 가능한 액세스 권한을 얻지 못하고 있습니다. (저는 지금 JMP 15 EA를 사용하고 있습니다. v3 문서에 설명된 대로 그의 네임스페이스에서 함수를 호출하려고 시도하는 것 외에는 다른 작업을 하지 않았습니다.)
질문:
1. Text to Columns()의 기본 제공 버전을 사용한다고 가정하면 생성된 열의 이름(또는 적어도 생성된 열의 *수*)을 가져오는 좋은 방법은 무엇입니까?
2. JP의 v3를 사용하는 것이 좋을까요? 그렇다면 요즘에는 어떻게 호출 가능하게 만들 수 있을까요?
남자
Re: Text to Columns 결과 열이것은 나를 위해 잘 작동합니다.
Add Custom Functions(
New Custom Function(
"my",
"Text to Columns",
// Wraps native Text to Columns() to make it return an associative array,
// containing the split column name(s) split (as keys), and the number of
// columns added (as values)
Function( {columns, delims, table = Current Data Table()},
// First parameter should be a list, but accept single value without brackets
If( Not( Is List( columns ) ),
columns = {columns}
);
columns = table << Get Column Reference( columns );
If( Not( Is String( delims ) ),
Throw()
);
n_cols = N Items( columns );
result = Associative Array();
For( i = 1, i <= n_cols, i++,
cols_before = N Cols( table );
Eval( Parse( Eval Insert( "^table^ << Text to Columns(delimiters(\!"^delims^\!"), columns(^columns[i]^))" ) ) );
cols_added = N Cols( table ) - cols_before;
result << Insert Item( columns[i] << Get Name, cols_added );
);
Return( result);
)
)
);예:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
my:Text to Columns({:Brush Delimited, :Floss Delimited}, ",", dt)
["Brush Delimited" => 4, "Floss Delimited" => 4]
Re: Text to Columns 결과 열내장된 Text to Columns()를 반환 값의 형태로 이 기능을 추가하는 사용자 함수로 래핑할 수 있을 것 같습니다.
남자Re: Text to Columns 결과 열다음은 추가된 열의 수를 얻는 간단한 방법입니다.
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 2 ),
New Column( "the text", Character, "Nominal", Set Values( {"A,B,C,D", "X,Y,Z"} ) )
);
nColNow = N Items( dt << get column names );
dt << text to columns( delimiter( "," ), columns( :the text ) );
colAdded = N Items( dt << get column names ) - nColNow;