更快速地读/写单元格你好
我有一个大数据文件(250k行乘2k列),其中包含来自电子集成电路器件(IC)的生产数据。
我有一个jsl脚本,我用它来评估结果并查找数据中的模式,但是在这么大的数据表中,完成运行需要几个小时。
读/写我正在使用的单元格 DT:MeasureX [行] 但该指令似乎没有执行效率,所以我切换到列(dt,“MeasureX”)[intRow] 而且这个执行起来要快20%。
是否有技巧来改善执行时间?比如在脚本执行时停止表窗口刷新...
谢谢
Re:更快地读/写单元格 @oscarmforero ,
由于您的数据是数字。尝试在矩阵上执行大部分操作会快得多。
dt = Current Data Table();
Mat = dt << Get As Matrix; // fetches all numeric data as a matrix
获得矩阵后,可以根据逻辑条件使用loc()进行选择。这是一个更详细的例子:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Get as Matrix
Mat = dt << Get as Matrix; // Note Matrix will only be 3 columns
// Selecting data in data table
SR = dt << Select Where(:height <= 65) << Get Selected Rows;
dt[SR,"height"] = 65;
dt << Clear Select;
// Selecting data in matrix
SR1 = Loc(Mat[0,2] <= 65);
Mat[SR1,2] = 65;
Re:更快地读/写单元格嗨马克
例如,我有下面的代码(这是需要更长时间执行的代码),我使用循环来读取单元格并再次比较它们的规格限制。如果单元格值超出限制,则读取并覆盖不同单元格的值。
numDataColumns = Current Data Table() << get column names( Numeric );
main_table = Current Data Table();<BR />
//Loop all columns with parametric data
For( intCol = 1, intCol <= N Items( numDataColumns ), intCol++,
Spec_Lims = Column( numDataColumns[intCol] ) << Get Property( "Spec Limits" );
Spec_USL_num = Try( Spec_Lims["USL"], . );
Spec_LSL_num = Try( Spec_Lims["LSL"], . );
USL_exist = Is Missing( Spec_USL_num ) == 0;
LSL_exist = Is Missing( Spec_LSL_num ) == 0;
//Loop all the selected rows (fails) and count the number of parametric fails and executed tests.
For( intRow = 1, intRow <= N Rows( Data Table( main_table ) ), intRow++,
If( Selected( Row State( Data Table( main_table ), intRow ) ) > 0,
If( Is Missing( Column( main_table, numDataColumns[intCol] )[intRow] ) == 0, //Only check for cells with data
//If both spec limits are available
If(
(USL_exist == 1 & LSL_exist == 1) & (Column( main_table, numDataColumns[intCol] )[intRow] > Spec_USL_num |
Column( main_table, numDataColumns[intCol] )[intRow] < Spec_LSL_num),
Column( main_table, "parFailCount" )[intRow] = Column( main_table, "parFailCount" )[intRow] + 1;<BR /> //log names of failing tests
Column( main_table, "failListNames" )[intRow] = Column( main_table, "failListNames" )[intRow] || Char( numDataColumns[intCol] )
|| ",";
);
//Considered only as executed tests when any of the limits are available.
If( USL_exist == 1 | LSL_exist == 1,
Column( main_table, "parExecutedTests" )[intRow] = Column( main_table, "parExecutedTests" )[intRow] + 1
);
)
)
);
);Re:更快地读/写单元格有许多方法可以提高脚本的性能,但该方法取决于脚本中的操作。你能描述一下脚本的作用吗?评估结果并查找数据中的模式 ?”