Data processing

Hello guys!
I have some issue in how to processing some data.
I have some files with 3 columns. The 1st column is a name of my sample. The 2nd column is a numerical sequence (very big sequence) starting from "1". And the 3rd column is a feature of each line, represented for a number (completely independent from the 2nd column). Something like this: (hypothetically)

scaffold_0 1 4
scaffold_0 2 4
scaffold_0 3 4
scaffold_0 4 6
scaffold_0 5 7
scaffold_0 6 7
scaffold_0 7 7
scaffold_0 8 7
scaffold_0 9 7

The problem is that when the value of 3rd column is zero, te line is not included in this file I have, generating something like this:

scaffold_0 1 4
scaffold_0 2 4
scaffold_0 8 7
scaffold_0 9 7

Note that the 2nd column jumps from 2 to 8 (the lines 3, 4, 5, 6 and 7 are not there because its respective 3rd column have a value = zero).

Question: Is there some command line that add the lines that are not present, resulting in something like this?

scaffold_0 1 4
scaffold_0 2 4
scaffold_0 3 0
scaffold_0 4 0
scaffold_0 5 0
scaffold_0 6 0
scaffold_0 7 0
scaffold_0 8 7
scaffold_0 9 7

Best regards..

awk '($2-p2)>1{
for(i=p2+1;i<$2;i++)
 print $1,i,0
}
{p2=$2}1' file

Worked perfectly.
Thank you a lot elixir_sinari :smiley: