f=open('filename','r') opensize=2**27 longlist= while 1: shortlist=[[l.split()[n] for n in [0,4,-2,-1]] for l in f.readlines(opensize)] if not list: break else: longlist.extend(shortlist)The script open the 'filename' file and next in the loop:
- read from that file lines of size close to 128 Mb (2**27),
- cut first, fifth, next to last and last column from each line,
- add created (temporary) list to the output list.
shortlistis not created the script will leave the loop (lines 6 and 7). It not obligatory, but I like to work with 2 powers, therefore opensize=2**27.