Compare values in multiple rows in one column using awk

I would like to compare values in column 8, and grep the ones where the different is > 1, columns 1 and 2 are the key for array.

Every 4 rows the records values in columns 1 and 2 changed. Then, the comparison in the column 8 need to be done for the 4 rows everytime columns 1 and 2 changed

input file

    47329,39785,2,12,10,351912.50,2533105.56,170.93,1
    47329,39785,2,12,28,351912.53,2533118.81,172.91,1
    47329,39785,3,6,7,351912.82,2533105.07,170.89,1
    47329,39785,3,6,20,351913.03,2533117.41,170.93,1
    47329,39797,2,12,10,352063.14,2533117.84,170.66,1
    47329,39797,2,12,28,352062.77,2533104.67,173.63,1
    47329,39797,3,6,7,352064.11,2533119.32,170.64,1
    47329,39797,3,6,20,352063.50,2533107.10,170.69,1
    47329,39809,2,12,10,352212.35,2533106.19,170.79,1
    47329,39809,2,12,28,352212.45,2533119.12,170.68,1
    47329,39809,3,6,7,352212.01,2533105.75,170.77,1
    47329,39809,3,6,20,352211.89,2533117.91,170.78,1
    47329,39821,3,6,7,352363.73,2533120.01,171.14,1
    47329,39821,3,6,20,352363.25,2533107.48,171.22,1
    47329,39821,2,12,10,352362.49,2533118.77,175.27,1
    47329,39821,2,12,28,352362.15,2533106.48,171.25,1

Desired output

 47329,39785,2,12,28,351912.53,2533118.81,172.91,1,
    47329,39797,2,12,28,352062.77,2533104.67,173.63,1
    47329,39821,2,12,10,352362.49,2533118.77,175.27,1

I have tried to substrat rows in column 8, but i am unable to get the desired output

 awk -F, '{$10 = $8 - prev8; prev8 = $8; print $0}' file

Thanks in advance for your help

Please be way more specific. What does "where the different is > 1" mean? How does this show up in your desired output? Which of the four lines should be printed? In your attempt, you reference $10 which doesn't exist in your input sample, and only in the first line, although empty, in your desired output.

awk -F, 'v[$1,$2] && ($8-v[$1,$2])>1;{v[$1,$2]=$8;}' file
1 Like

Try also (after some guesswork)

awk -F, '{IX = $1 FS $2} IX == OX && $8 - O8 > 1; {OX = IX; O8 = $8}' file
    47329,39785,2,12,28,351912.53,2533118.81,172.91,1
    47329,39797,2,12,28,352062.77,2533104.67,173.63,1
    47329,39821,2,12,10,352362.49,2533118.77,175.27,1

Many Thanks for the help