關於 JSL 的初學者問題我想使用 JSL 將選定的行保存在 csv 或 jmp 文件中。 但我無法做到這一點 誰能告訴我如何做到這一點?
我嘗試了以下代碼,但保存它的方法似乎是錯誤的:
f = Function( {a},
theRows = Current Data Table() << get selected rows;
Show( theRows );
);
rs = Current Data Table() << make row state handler( f );
filepath = "C:\Users\abc\Desktop\trial";
rs << save( filepath || "\" || "part1.jmp" );分析數據表腳本編寫視窗回复:關於 JSL 的初學者問題有很多方法可以處理這個問題。我假設您將在之前的討論中將此 JSL 與 Partition() 平台一起使用,這就是我接近解決方案的方式
f = Function( {a},
theRows = Current Data Table() << get selected rows;
Show( theRows );
);
rs = Current Data Table() << make row state handler( f );
filepath = "C:\Users\abc\Desktop\trial";
rs << save( filepath || "\" || "part1.jmp" );回复:關於 JSL 的初學者問題是的,它與 Partition() 平台有關 但是當我運行代碼保存數據時,我無法保存它。 我附上了我的代碼,因為我無法理解代碼在哪裡失敗,因為在日誌中它沒有顯示任何錯誤。
回复:關於 JSL 的初學者問題我認為您需要查看程序流程,您無法在定義行之前保存文件。
可能是這個小例子展示瞭如何處理,當分區關閉時,它將從分區平台中選擇的行保存在一個表中。 但正如吉姆所說:很多方法!
Names Default To Here( 1 );
// opens partition platform on Big Class data table
// when rows are selected, and platform is closed, selected rows are saved in separate data table
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
obj = Partition( Y( :weight ), X( :sex, :height ), Method( "Decision Tree" ), Validation Portion( .2 ) );
obj << split best();
// When partition window is closed do this:
obj << on close(
If( N Items( dt << get selected rows() ) > 0,
dtTemp = dt << subset( invisible, selected rows( 1 ), selected columns( 0 ) );
filepath = "$TEMP";
Close( dttemp, save( filepath || "\" || "part1.jmp" ) );
// open file again
Open( filepath || "\" || "part1.jmp" );
)
);
回复:關於 JSL 的初學者問題我在上次回復中提供的 JSL 中犯了一個錯誤。從那以後,我更正了我的回答。
在此回復中,我擴展了您提供的 JSL,並提供了一個完整的示例,該示例將在每次指定新的 Select Rows 時保存子集表。
當 Partition() 窗口關閉時,行狀態處理程序也被消除。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
tableCount = 0;
theRows = [];
f = Function( {a},
// Set dupRows to the previously selected rows
dupRows = theRows;
// Get the current selected rows
theRows = Current Data Table() << get selected rows;
If( N Rows( theRows ) > 0,
// check to see if there are the same number of rows and if yes
// then validate the rows are different rows before saving
If( N Rows( theRows ) == N Rows( dupRows ),
If( Sum( dupRows == theRows ) != N Rows( theRows ),
tableCount++;
dtTemp = dt << subset( invisible, selected rows( 1 ), selected columns( 0 ) );
filepath = "$TEMP";
Close(
dtTemp,
save( filepath || "\" || "part" || Char( tableCount ) || ".jmp" )
);
Current Data Table( dt );
);
,
// If not the same number of selected rows, save the subset
tableCount++;
Show( tableCount );
dtTemp = dt << subset( invisible, selected rows( 1 ), selected columns( 0 ) );
filepath = "$TEMP";
Close( dtTemp, save( filepath || "\" || "part" || Char( tableCount ) || ".jmp" ) );
Current Data Table( dt );
)
);
);
rs = Current Data Table() << make row state handler( f );
obj = Partition(
Y( :NPN1 ),
X( :PNP1, :PNP2, :PNP3, :PNP4, :NPN2, :NPN3, :NPN4 ),
Method( "Decision Tree" ),
Validation Portion( .2 )
);
obj << ShowGraph( 0 );
obj << SplitBest( 4 );
obj << Show Split Count( 1 );
obj << Show Split Prob( 1 );
Wait( .5 );
//obj << Save Predicteds;
obj << on close( Clear Symbols( rs ) );