[Numpy-discussion] bug in genfromtxt for python 3.2
josef.pktd@gmai...
josef.pktd@gmai...
Tue Mar 29 01:29:04 CDT 2011
numpy/lib/test_io.py only uses StringIO in the test, no actual csv file
If I give the filename than I get a TypeError: Can't convert 'bytes'
object to str implicitly
from the statsmodels mailing list example
>>>> data = recfromtxt(open('./star98.csv', "U"), delimiter=",", skip_header=1, dtype=float)
> Traceback (most recent call last):
> File "<pyshell#30>", line 1, in <module>
> data = recfromtxt(open('./star98.csv', "U"), delimiter=",",
> skip_header=1, dtype=float)
> File "C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py",
> line 1633, in recfromtxt
> output = genfromtxt(fname, **kwargs)
> File "C:\Programs\Python32\lib\site-packages\numpy\lib\npyio.py",
> line 1181, in genfromtxt
> first_values = split_line(first_line)
> File "C:\Programs\Python32\lib\site-packages\numpy\lib\_iotools.py",
> line 206, in _delimited_splitter
> line = line.split(self.comments)[0].strip(asbytes(" \r\n"))
> TypeError: Can't convert 'bytes' object to str implicitly
>
> line 1184 in npyio (py32 sourcefile)
>
> if isinstance(fname, str):
> fhd = np.lib._datasource.open(fname, 'U')
>
> seems to be the culprit for my case
changing to binary solved this problem for me
fhd = np.lib._datasource.open(fname, 'Ub')
(I still have other errors but don't know yet where they are coming from.)
Almost all problem with porting statsmodels to python 3.2 so far are
input related, mainly reading csv files which are heavily used in the
tests. All the "real" code seems to work fine with numpy and scipy
(and matplotlib so far) for python 3.2
Josef
More information about the NumPy-Discussion
mailing list