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

Alan G Isaac aisaac@american....
Thu Feb 28 00:12:02 CST 2008


> 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?

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

Cheers,
Alan Isaac





More information about the Numpy-discussion mailing list