I have a file that has a repeated number of blocks of different sizes as in below:
For each block, I want to print only the lines that start with 'Domain' and 'Referer'. This is how I approached the problem:
f = open('testconn.txt').read() lines = ["Conn:" , "Domain:" , "Referer"] for record in f.split('\n\n'): for i in record: if record in lines: print record
It gives no error and prints nothing either. Any help is appreciated.