根據時間戳更新表你好,
我有兩張桌子。 (甲和乙)
表 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];
);
回覆:根據時間戳更新表對查找表進行排序並使用本地排序() 。 檢查腳本索引中的函數以了解其工作原理。