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

Lisandro Dalcin dalcinl@gmail....
Tue Feb 26 13:44:38 CST 2008

Dear all,

I believe the current 'loadtxt' function is broken if file does not
end in newline. The problem is at the last line of this fragment:

    for i,line in enumerate(fh):
        if i<skiprows: continue
        line = line[:line.find(comments)].strip()

This is because `str.find()` (yet again!) returns -1 (minus one) on
failure. Therefore, if a input ASCII file is missing the newline at
the very end, the last character is chopped.

Can someone file a bug or perhaps fix it? I'm very, very busy as to do
any of that right now, sorry.


Lisandro Dalcín
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

More information about the Numpy-discussion mailing list