Reading text file with wierd file extension?

Diez B. Roggisch deets at nospam.web.de
Mon Feb 2 14:28:07 EST 2009


> Hi Mike,
> 
> maybe it's not a "true" text file? Opening it in Microsoft Notepad
> gives an unformatted view of the file (text with no line wrapping,
> just the end-of-line square box character followed by more text, end-
> of-line character, etc). Wordpad opens it properly i.e. respects the
> end-of-line wrapping. I'm unsure of how these files are being
> generated, I was just given them and told they wanted to be able to
> read them.


Sounds like a unix-line-ended textfile. Python has no problems reading 
these, and frankly I'm a bit wondering why you have that IOError -but 
then, on windows *anything* is possible.

You can try to open the file using the "rb" flag, which opens it in binary.

However, Python doesn't care about any extensions, that must be 
something else you did different.

 > How do I collect the traceback to post it?

Copy and paste from the console or wherever you run the script?

Diez



More information about the Python-list mailing list