• Compare next sequence result in Generator

def lines():
    with open('p_input.txt') as f:
        for line in f:
            yield line.strip().split('|')

def parse_2(*file): 
    result_2 = []
    rows_generator = lines()
    next_row = next(rows_generator, None)
    for line in lines(): 
        if line[0] == next_row[0]:
            if line[2] != next_row[2]:
                if int(line[3]) - int(next_row[3]) < 60:
    return result_2

it = lines()
print parse_2(*it)


Sorry got a general question about coding, kindly let me know if it violates the forum's general rule. Thanks to checkio, I have a lot of fun learning python. And I have tried to combine things I learn here to some new topics. I create a generator to read 1 row of data at a time. And I need to filter the result by comparing rows of data. For example, total of 10 rows, I need to compare from (row 1 to row 2, 3, 4, ...10), then move to the next comparison of (row 2 to row 3, 4,... 10). However, it seems my code only stays at row 1 comparing to the rest rows, why is that so? I had applied a for loop, shouldn't it keeps rolling to row 2 and keep comparing?