Not able to read blank lines and spaces on a small text file

Peter Hickman peter at semantico.com
Mon Sep 13 17:04:14 CEST 2004


Ruben wrote:
> Hello.
> 
> I am trying to read a small text file using the readline statement. I
> can only read the first 2 records from the file. It stops at the blank
> lines or at lines with only spaces. I have a while statement checking
> for an empty string "" which I understand represents an EOF in Python.
> The text file has some blank lines with spaces and other with blanks.

My brain is not really working but a blank line is not how python processes a 
the EOF.

Try something like:

input_file = open("C:/Documents and Settings/ruben/My 
Documents/Python/text.txt", "r")

for line in input_file:
	print line,



More information about the Python-list mailing list