In a Python script transform, I have a historian dataset that looks like this. It might have any number of columns from 1 to 10 in addition to the t_stamp
column. I want to builld it into a new dataset using only rows that come after a given timestamp -- in this case, it is 7:00am. I want to also insert a row at the exact 7:00:00 AM mark with 0 for each value. Basically I am pruning times before a cutoff time and initializing each column.
I started along this path:
dataset = # (see above)
cutoffDate = "2024-03-15 7:00:00 AM"
for i in range(dataset.getRowCount()):
t_stamp = dataset.getValueAt(i,"t_stamp")
if t_stamp >= cutoffDate:
# (insert the entire row into a new dataset...)
...But kind of got stuck when I realized there's not an easy way to grab a row of data out of a dataset and throw it into a new dataset (or maybe there is?). Would a pyDataSet work better?
Alternatively, is there a way for system.tag.queryTagHistory
to stop grabbing "early" values? My dataset comes from that function, and even when supplied with the proper cutoffDate
of 2024-03-15 7:00:00 AM
, it is grabbing a handful of values before this timestamp (in some cases but not all). Any guidance is appreciated.