根据时间戳更新表你好,
我有两张桌子。 (甲和乙)
表 A 包含(测试期间的 2000 个事件)标记时间段开始的事件以及特定时间戳处的时间段名称(下划线是标题)
时间戳、期间
2021年12月30日 17:35:49.1, A
2021年12月30日 17:39:36.8, B
...
因此期间 A 介于“30-12-2021 17:35:49.1”和“30-12-2021 17:39:36.8”之间
表 B 是一个日志文件,记录了大约 6000000 个数据点的数据以及时间戳(下划线是标题)
时间戳、传感器1、传感器2、传感器3 ,...
2021 年 12 月 30 日 17:37:21.2,值,值,值,...
2021 年 12 月 30 日 17:37:22.2,值,值,值,...
2021 年 12 月 30 日 17:37:23.2,值,值,值,...
我想向表 B 添加一个 now 列,其中包含基于 B 中时间戳值的表 A 中的周期值。
如果 B 中的时间戳大于或等于表 A 中的行 (N) 中的时间戳并且也小于表 A 中的行 (N+1) 中的时间戳,则将为表中的该记录分配行 (N) 中的周期值B(B 中的时间戳位于 A 中的两个时间戳之间)
有什么建议么?
谢谢
视窗回复:根据时间戳更新表通过将循环更改为解决了这个问题
For( i = 1, i <= N Rows( rows ), i++,
theRow = rows[i];
//show(theRow);
//show(subscript(dta,theRow,15));
subscript(dtb,i,8) = subscript(dta,theRow,17);
subscript(dtb,i,9) = subscript(dta,theRow,15);
subscript(dtb,i,10) = subscript(dta,theRow,16);
);
但是,如果有更快的方法来运行它,我很乐意学习。 谢谢。
回复:根据时间戳更新表非常感谢 ErraticAttach 和 txnelson
吉姆,索引有没有可能是倒退的?
Loc 排序是为 B 中的每一行获取表 A 中的行号,其中包含我想要放入表 B 中的信息
但是,我在循环内收到有关范围界定的错误。
1.如果我理解正确的话,“行”应该与表B具有相同的行数
2. 参数“i”从1增加到B中的行数。
3. 在循环的每次迭代中,参数“theRow”被分配“rows”中相应的第i个数字。
所以它实际上保存了一个数字,代表表A中保存我想要的数据的特定行。
4.所以现在我们需要做的就是读取该行A中相应列中的值并将其放入我想要的列中B的第i行中。
但是,我收到有关“范围数据表访问需要访问或评估...的数据表列或变量”的错误
查看代码,我认为脚本引用了错误的数字作为索引。
所以我在 [i] 和 [theRow] 之间切换
”
For( i = 1, i <= N Rows( rows ), i++,
theRow = rows[i];
dta:sensor1[theRow] = dtb:sensor1[i];
dta:sensor2[theRow] = dtb:sensor2[i];
dta:sensor3[theRow] = dtb:sensor3[i];
);
实际上应该读
For( i = 1, i <= N Rows( rows ), i++,
theRow = rows[i];
dta:sensor1[i] = dtb:sensor1[theRow];
dta:sensor2[i] = dtb:sensor2[theRow];
dta:sensor3[i] = dtb:sensor3[theRow];
);
但这也无济于事。
我对JSL还不熟悉,难道是我指定值或列行的方式不正确?
非常感谢。
回复:根据时间戳更新表这是一个可能的解决方案,使用@ErraticAttack关于使用方法的建议。
Names Default To Here( 1 );
dta = Data Table( "table A" );
dtb = Data Table( "table B" );
// Place all timestamp values from Table A & B
timesa = dta:timestamp << get values;
timesb = dtb:timestamp << get values;
// Find the row to add the data to
rows = Loc Sorted( timesa, timesb );
// Add the new columns to Table A
dta << New Column( "sensor1" );
dta << New Column( "sensor2" );
dta << New Column( "sensor3" );
// Loop through matrix rows and add the records to the appropriate
// row in Table A
For( i = 1, i <= N Rows( rows ), i++,
theRow = rows[i];
dta:sensor1[theRow] = dtb:sensor1[i];
dta:sensor2[theRow] = dtb:sensor2[i];
dta:sensor3[theRow] = dtb:sensor3[i];
);
回复:根据时间戳更新表对查找表进行排序并使用本地排序() 。 检查脚本索引中的函数以了解其工作原理。