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

Robert Kern robert.kern@gmail....
Thu Feb 28 00:39:51 CST 2008


On Thu, Feb 28, 2008 at 12:12 AM, Alan G Isaac <aisaac@american.edu> wrote:
> > On Wed, 27 Feb 2008, Robert Kern apparently wrote:
>  >> Fixed in r4827.
>
>
>
>  > On Wed, Feb 27, 2008 at 6:31 PM, Christopher Barker wrote:
>  >> For the record, this is the fixed version:
>  >>         comment_start = line.find(comments)
>  >>          if comment_start > 0:
>  >>              line = line[:comments_start].strip()
>  >>          else:
>  >>              line = line.strip()
>
>
>  Three problems.
>  1. I do not see this change here:
>  <URL:http://svn.scipy.org/svn/numpy/trunk/numpy/core/numeric.py>
>  Am I looking in the wrong place?

I fixed the version in numpy/lib/io.py. I didn't know there was a
second version lying around. It was moved there during in the lib_io
branch but did not get removed from numpy/core during the merge.

>  2. Can I assume this was not cut and past?
>  Otherwise, I see two problems.
>
>     2a.  comment_start vs. comments_start (spelling)
>     2b.  >0 instead of >=0   (e.g., "#try me!" would not be skipped)
>
>  So I think the desired lines are actually::
>
>
>     comment_start = line.find(comments)
>     if comment_start >= 0:
>         line = line[:comment_start].strip()
>     else:
>         line = line.strip()
>     return line

The errors were real. They are now fixed, thank you.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list