I have a .csv file i need to loop over, and then inside a loop, i want to check the value of the next line every iteration. I can’t seem to get it to work properly, as it skips the line i was looking ahead in the next iteration.
import csv
file_object = open('file.csv', 'r')
reader = csv.reader(file_object, delimiter = ';')
for line in reader:
next_line = reader.next()
# It now reads the next line and doesn't iterate over it again in the next
# iteration. However, i want it to still iterate over it in the next iteration.
Thank you very much!
You could keep track of both the current and the next line “manually:”