[NumPy-Tickets] [NumPy] #1071: loadtxt fails if the last column contains empty value
NumPy Trac
numpy-tickets@scipy....
Wed Mar 30 13:29:37 CDT 2011
#1071: loadtxt fails if the last column contains empty value
---------------------------------+------------------------------------------
Reporter: Electrion | Owner: somebody
Type: defect | Status: needs_review
Priority: normal | Milestone: 1.6.0
Component: numpy.lib | Version: devel
Keywords: loadtxt ascii strip |
---------------------------------+------------------------------------------
Comment(by bsouthey):
This ticket is invalid because the loadtxt docstring clearly states:
{{{
Each row in the text file must have the same number of values.
}}}
Here ''values'' means having the same type throughout the input. That is
you can not mix integers, floats and strings:
{{
>>> c = StringIO("0 1\n2 3")
>>> np.loadtxt(c)
array([[ 0., 1.],
[ 2., 3.]])
>>> d = StringIO("0 '1'\n2 '3'")
>>> np.loadtxt(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 783,
in loadtxt
items = [conv(val) for (conv, val) in zip(converters, vals)]
ValueError: could not convert string to float: '1'
}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1071#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list