JSL은 열 형식을 설정하지 않습니다.안녕하세요 여러분,
한 테이블의 열 이름, 데이터 유형, 모델링 유형 및 형식을 새 테이블로 복사하려고 하는데 열 형식을 설정하려고 하면 절대 적용되지 않고 "최상"으로 되돌아갑니다. 나는 이것에 대해 잠시 동안 머리를 부딪쳤고 그것이 작동하지 않는 이유에 완전히 당황했습니다. 아래는 내 코드이며 열 형식을 보여주는 결과 출력은 유효하지만 고정되지 않습니다. 로그에 보고된 오류가 없습니다. 아무도 내가 뭘 잘못하고 있는지 볼 수 있습니까?
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
For( i = 1, i <= N Items( colNames ), i++,
colType = Column( data, colNames[i] ) << Get Data Type;
colModel = Column( data, colNames[i] ) << Get Modeling Type;
colFormat = Column( data, colNames[i] ) << Get Format;
Show( colNames[i] );
Show( colType );
Show( colModel );
<STRONG> Show( colFormat );</STRONG>
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
If( colType != "Character",
newCol << Format( colFormat );
<STRONG> Show( newCol << Get Format );</STRONG>
);
);
colNames[i] = "Label";
colType = "Character";
colModel = "Nominal";
colFormat = Format("Best");
colNames[i] = "Start_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);</STRONG>
colNames[i] = "End_Time";
colType = "Numeric";
colModel = "Continuous";
<STRONG>colFormat = Format("m/d/y h:m:s", 23, 0);
newCol << Get Format = Format("Best", 10);</STRONG>보너스 후속 질문 : 컬럼 초기화 후 타입을 설정한 위의 코드를 통해서만 컬럼 데이터와 모델링 타입을 설정할 수 있을 것 같습니다. 아래 줄을 실행하려고 할 때 열이 초기화되지 않는 이유는 무엇입니까?
newCol = summaryTable << New Column( colNames[i], colType, colModel );
스크립팅Re: JSL이 열 형식을 설정하지 않습니다.감사합니다. 테이블을 복사하고 행을 삭제하는 것을 고려했습니다. 데이터 테이블은 약 24개의 열로 구성되며 잠재적으로 수백 개의 행을 포함할 수 있습니다. 24개의 열을 반복적으로 생성하는 것이 잠재적으로 수백 개의 행을 삭제하는 것보다 더 효율적일 수 있다고 생각했습니다.@pmroz 의 하위 집합 접근 방식은 영리하지만 그냥 사용할 수도 있습니다.
Re: JSL이 열 형식을 설정하지 않습니다.테이블이 크지 않고 Mark의 생각을 바탕으로 다음과 같이 할 수 있다고 가정합니다.
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Eval(dt << getScript);
dt2 << selectAllRows;
dt2 << deleteRows;Re: JSL이 열 형식을 설정하지 않습니다.하위 집합을 사용하는 더 간단한 논리:
data = New Table( "Test Data", Add Rows( 3 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Fixed Dec", 8, 0 ),
Set Values( [1, 2, 3] )
),
New Column( "Column 2", Character, "Nominal", Set Values( {"c", "b", "a"} ) ),
New Column( "Column 3", Numeric, "Continuous", Format( "m/d/y", 10 ),
Input Format( "m/d/y" ),
Set Values( [3630873600, 3633552000, 3635971200] )
)
);
summaryTable = data << Subset( Rows( [1] ));
summarytable << delete rows([1]) << set name( "Results Summary");
Re: JSL이 열 형식을 설정하지 않습니다.답변 감사합니다. "데이터"가 여러 SQL 쿼리 및 계산에서 생성된 이미 존재하는 테이블이라는 것을 언급하지 못한 것 같습니다. 실제로 부분 집합화하지 않고 "데이터"와 동일한 열로 요약 테이블을 조합하고 싶습니다. 나중에 조각 단위로 행을 채웁니다.
@pmroz 귀하의 접근 방식이 효과가 있습니다. 감사합니다! 여전히 포인터가 작동하지 않는 이유를 이해하지 못하지만, 이 문제에 너무 익숙해져서 더 이상 신경 쓰지 않습니다.
Re: JSL이 열 형식을 설정하지 않습니다.이 코드는 다음을 수행합니다.
data = New Table( "Test Data", Add Rows( 3 ),
New Column( "Column 1", Numeric, "Continuous", Format( "Fixed Dec", 8, 0 ),
Set Values( [1, 2, 3] )
),
New Column( "Column 2", Character, "Nominal", Set Values( {"c", "b", "a"} ) ),
New Column( "Column 3", Numeric, "Continuous", Format( "m/d/y", 10 ),
Input Format( "m/d/y" ),
Set Values( [3630873600, 3633552000, 3635971200] )
)
);
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
For( i = 1, i <= N Items( colNames ), i++,
colType = Column( data, colNames[i] ) << Get Data Type;
colModel = Column( data, colNames[i] ) << Get Modeling Type;
colFormat = char(Column( data, colNames[i] ) << Get Format);
Show( colNames[i] );
Show( colType );
Show( colModel );
Show( colFormat );
newCol = summaryTable << New Column( colNames[i] );
newCol << Data Type( colType ) << Modeling Type( colModel );
if (coltype != "Character",
new_expr = "newcol << " || colformat;
eval(parse(new_expr));
);
);Re: JSL이 열 형식을 설정하지 않습니다.원본 데이터 테이블의 복사본을 저장하고 복사본을 열어 계속하는 것이 더 쉬울까요?
Re: JSL이 열 형식을 설정하지 않습니다.안녕,
먼저 "데이터"가 정의되어 있지 않다고 생각합니다.
Clear Globals();
summaryTable = New Table( "Results Summary" );
colNames = data << Get Column Names( string );
결과는
Data Table( "Results Summary" )
//:*/
colNames = data << Get Column Names( string );
/*:
Send Expects Scriptable Object in access or evaluation of 'Send' , data << /*###*/Get Column Names( string ) /*###*/
In the following script, error marked by /*###*/
colNames = data << /*###*/Get Column Names( string ) /*###*/
{}