Skip to content

genfromtxt bug with delimiter is int type (Trac #1656) #2252

@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/1656 on 2010-10-31 by trac user sunqiang, assigned to @pierregm.

from userguide http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html#the-delimiter-argument (the second example):

import numpy as np
from StringIO import StringIO
data = " 1 2 3\n 4 5 67\n890123 4"

np.genfromtxt(StringIO(data), delimiter=3)

Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 1451, in genfrom
txt
raise ValueError(errmsg)
ValueError: Some errors were detected !
Line #3 (got 3 columns instead of 4)

np.version
'1.5.1rc1'

quick and dirty fix:
insert "line = line.rstrip()" at line 212 of C:\Python27\Lib\site-packages\numpy\lib_iotools.py, aka, the first line of method _fixedwidth_splitter(self, line) of class LineSplitter:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions