Pregunta de principiante sobre JSLQuiero guardar las filas seleccionadas en un archivo csv o jmp usando JSL. Pero no puedo hacerlo. ¿Alguien puede decirme cómo hacerlo?
Intenté con el siguiente código, pero la forma de guardarlo parece ser incorrecta:
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" );AnalíticaTabla de datosScriptingVentanasRe: Pregunta de principiante sobre JSLHay muchas formas de manejar esto.Supongo que usará este JSL con la plataforma Partition () de su discusión anterior, esta es la forma en que abordaría la solución
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" );Re: Pregunta de principiante sobre JSLSí, está relacionado con la plataforma Partition () Pero cuando ejecuto el código para guardar los datos, no puedo guardarlos. Adjunté mi código porque no puedo entender dónde falla el código, ya que en el registro no muestra ningún error.
Re: Pregunta de principiante sobre JSLCreo que necesita ver el flujo del programa, no puede guardar el archivo antes de que se definan las filas.
Puede ser que este pequeño ejemplo muestre cómo puede manejar, guarda las filas seleccionadas de la plataforma de partición en una tabla, cuando la partición está cerrada. Pero como mencionó Jim: ¡de muchas maneras!
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" );
)
);
Re: Pregunta de principiante sobre JSLCometí un error en el JSL que proporcioné en mi última respuesta.Desde entonces he corregido mi respuesta.
En esta respuesta, he ampliado su JSL proporcionado y proporcioné un ejemplo completo que guardará la tabla subconjuntada cada vez que se especifique una nueva Seleccionar filas.
El controlador de estado de fila también se elimina cuando se cierra la ventana 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 ) );