[Numpy-discussion] loadtxt broken if file does not end in newline

Christopher Barker Chris.Barker@noaa....
Wed Feb 27 18:31:50 CST 2008

Robert Kern wrote:
> Fixed in r4827.

Thanks Robert. For the record, this is the fixed version:

        comment_start = line.find(comments)
         if comment_start > 0:
             line = line[:comments_start].strip()
             line = line.strip()

Just as a matter of interest, why this, rather than line.index()? Are 
exceptions slower than an if test?


I don't see any io tests in:


Is that where they should be? It seems like a good idea to have a few...

If I did find the time to write some tests -- how does one go about it 
for this sort of thing? Do I put a couple sample input files in SVN? Or 
does the test code write out the sample files, then read them in to 
test? Or maybe do it all in memory with sStringIO or something. Are 
there any examples of tests of file reading code that I could borrow from?


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception


More information about the Numpy-discussion mailing list