取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
选择语言 隐藏翻译栏
查看原发布的话题

关于 JSL 的初学者问题

shasha_2
Level III

我想使用 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" );

这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。

1 个已接受解答

已接受的解答
txnelson
Super User

回复:关于 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 ) );

4 条回复4
txnelson
Super User

回复:关于 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" );

这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。

shasha_2
Level III

回复:关于 JSL 的初学者问题

是的,它与 Partition() 平台有关 但是当我运行代码保存数据时,我无法保存它。 我附上了我的代码,因为我无法理解代码在哪里失败,因为在日志中它没有显示任何错误。

这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。

Georg
Level VII

回复:关于 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" );
 )
);

这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。

txnelson
Super User

回复:关于 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 ) );

这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。