=== Subject: [Tutor] raw_input() Dear group: I have a large file 3GB. Each line is a tab delim file. example lines of it: 585 chr1 433 433 rs56289060 0 + - - -/C genomic insertion unknown 0 0 unknown between 1 585 chr1 491 492 rs55998931 0 + C C C/T genomic single unknown 0 0 unknown exact 1 585 chr1 518 519 rs62636508 0 + G G C/G genomic single unknown 0 0 unknown exact 1 585 chr1 582 583 rs58108140 0 + G G A/G genomic single unknown 0 0 unknown exact 1 Now I dont want to load this entire file. I want to give each line as an input and print selective lines. For example: x1.py = second = raw_input() x = second.split('\t') y = x[1:] print '\t'.join(y) %cat mybigfile.rod | python x1.py chr1 433 433 rs56289060 0 + - - -/C genomic insertion unknown 0 0 unknown between 1 My question: this program is only printing first line. It is not processing every line that cat spits to x1.py. how do I print every line. Subject: Re: [Tutor] raw_input() Here it worked after trying a while loop: x1.py = while True: second = raw_input() x = second.split('\t') y = x[1:] print '\t'.join(y) %cat mybigfile.rod | python x1.py Traceback (most recent call last): File "x1.py", line 2, in second = raw_input() EOFError: EOF when reading a line How to notify that at EOF break and suppress exception. Subject: Re: [Tutor] raw_input() > I have a large file 3GB. Each line is a tab delim file. [...] > Now I dont want to load this entire file. I want to give each line as > an input and print selective lines. datafile = open("somefile.data", "r") for line in datafile: print line will print each line. If you want to print selected lines, you have to explain what the condition is that decides whether to print it or not. I'm going to make something up: suppose you want the line to only print if the eighth column is "A": def condition(line): line = line.strip() fields = line.split('\t') return fields[7].strip().upper() == "A" datafile = open("somefile.data", "r") for line in datafile: if condition(line): print line will print only the lines where column 8 is the letter A. Subject: Re: [Tutor] raw_input() > x1.py = > > second = raw_input() > x = second.split('\t') > y = x[1:] > print '\t'.join(y) > > > %cat mybigfile.rod | python x1.py > chr1 433 433 rs56289060 0 > + - - -/C genomic insertion unknown 0 0 > unknown between 1 > > > My question: > > this program is only printing first line. It is not processing every line > that cat spits to x1.py. > how do I print every line. You need to read every line. But since you appear to be on Unix have you looked at the cut command which would appear to do what you want directly? Unless you just want the learning experience. ===