Process a file in Python

Simple snippet which processes each line of a file. Each line of the file contained data in space separated columns. I was interested in row where the 2nd and 3rd columns differed.

f = open("text.txt")

for line in f:
words = line.split()
if len(words[1]) != len(words[2]):
print line

f.close()

0 comments: