I'm trying to read two files and comparing two columns with dates in them and if the dates are the same, then I want to compare two values corresponding to the dates. I want to read one line of file 1 with all the lines of file 2 and then the next line of line 1 with all the lines of file 2. However, when I try to compare the dates, my for loop that reads the two files only runs once. How do I make it so that I can compare file 1 and file 2 as i said earlier?
with open('file1.txt') as f1:
with open('file2.txt') as f2:
for i in (f1):
column1f1 = (i.split()[0])
column2f1 = (i.split()[1])
for j in (f2):
column1f2 = (j.split()[0])
column2f2 = (j.split()[1])
print(column1f1)
print(column1f2)
I expected this to give me the entirety of file 2 with the first line of file 1, and then repeated for all the lines of file 1, but instead it only runs for the first line of file 1 and then stops.