Hi All,
I have a log file of temperature at unequal intervals and the duration between them.
I want to clean the dataset so there will be no repeating temperatures and no short intervals between the same temperature measurements.
To delete the repetitions I use the following code:
Repeats = dt << get rows where( Lag( :Temperature, 1 ) == :Temperature );
dt << delete rows( repeats );
For the short jumps between same temperatures I use:
Jumps = dt << get rows where( And( Lag( :Temperature, 1 ) == Lag( :Temperature, -1 ), :Duration < 2 ) );
dt << delete rows( Jumps );
this is done repetitively since once the Jumps are cleaned there could be new Repeats and the other way round. So I use it in a for loop. I can always do this excessively (setting i to a high number) but it is inefficient.
Any suggestions to improve the loop so it stops when there are no repeats of Jumps?
The overall script looks like this:
dt = New Table( "Log File", Add Rows( 500 ) );
dt << New Column( "Temperature",
Set Property( "Value Colors", {1 = -13977687, 2 = -3780931, 3 = -4222943, 4 = -13596966, 5 = -2211217} ),
Color Cell by Value
);
For Each Row( dt:Temperature = Random Integer( 5 ) );
dt << New Column( "Duration" );
For Each Row( dt:Duration = Random Integer( 3 ) );
// delete repeating rows and short jumps
For( i = 1, i <= 5, i++,
Repeats = dt << get rows where( Lag( :Temperature, 1 ) == :Temperature );
dt << delete rows( repeats );
Jumps = dt << get rows where( And( Lag( :Temperature, 1 ) == Lag( :Temperature, -1 ), :Duration < 2 ) );
dt << delete rows( Jumps );
);