我有一个数据表,它由多行单独的测量值组成,我在执行表拆分功能之前要对其进行修剪,但是我想删除一些冗余测量值,但当前代码我有问题我正在使用的速度非常慢,而且对于我需要的东西可能效率低下。
背景资料:
- 每行都是对连续执行的一块材料进行单独自动测量的结果,并生成包含以下列的报告:
- 分配给每块材料的唯一部件 ID [ PartID ]
- 与用于创建单个材料 [LotID] 的原材料相关联的批次 ID
- 所执行测量的实际测量值 [值]
- 基于测量值分配的测量结果(通过/失败/返工)[结果]
- 测量时间戳 [ Date_Created ]
我的设备为每件材料生成数十行测量值,并在每个报告中处理数千件材料 - 然后将这些报告作为我的原始数据表输入 JMP。每个报告还包含多个批次,因此数据表有多个对“PartID = 1”的引用,因为每个批次都有一个从 1 开始的序列号,因此我需要同时使用 PartID 和 LotID 来引用给定的材料。在结果为“返工”的情况下,测量设备停止对该单件材料的任何进一步测量,重新定位该材料,并将其返回到生产线的起点,重新测量所有先前的测试材料,但仍保留与该材料相关联的唯一零件 ID。
期望的结果:
我想使用脚本来遍历数据表并消除所有测量结果(包括)返工结果,因为在返工后,所有测量都会重复,返工会影响测量值。为此,我目前正在使用 JSL 脚本遍历每一行并执行以下操作:
- 识别结果是否为“返工”;如果是这样,请执行以下操作:
- 将给定材料的 PartID 标识为“xPartID”
- 将给定材料的 LotID 标识为“xLot”
- 将给定测量的 Date_Created 标识为“xDate”
- 选择并删除 (PartID = xPartID) 和 (LotID = xLot) 和 (Date_Created <= xDate) 的所有行
- 如果结果不是“返工”,则退出循环,无需继续。
我一直在极度减速,基本上代码会导致程序崩溃。如果我逐步运行它,它似乎可以工作,但如果让它运行它最终会死掉。 这是实际的代码:
//Recoding the two potential "Rework" results into a shared value "aRework"; putting the letter "a" in front of it so if I sort by the column ascending then all of these values are at the start of the list, to hopefully make it easier and faster to process them.
dt << Recode Column(
dt:result,
{Map Value(
_rcOrig,
{"FailOnHighRework", "aRework",
"FailOnLowRework", "aRework"},
Unmatched( _rcNow )
)},
Update Properties( 1 ),
Target Column( :result )
);
//Sorting the table using the result column after the recode, so all of the rework rows are at the start of the table
SortColumn = "result";
dt << Sort( By( :result ), Replace Table, Order( Ascending ), Suppress formula evaluation( 1 ) );
//now run the row-by-row script
dt << begin data update;
for each row(
If( :result == "aRework",
xRow = Row();
xPartID=:PartID[Row()];
xLot=:lot[Row()];
xDate=:date_created[Row()];
dt <<SELECT where=""></SELECT>我正在使用 JMP 16.2.0 (570548)。