Hi,

I noticed there is an odd issue when I am trying to convert a recarray to
list.  See below for the example/test case.

$ cat a.csv
date,count
2011-07-25,91
2011-07-26,118
$ cat b.csv
name,count
foo,1233
bar,100

$ python

>>> from matplotlib import mlab
>>> import numpy as np

>>> a = mlab.csv2rec('a.csv')
>>> b = mlab.csv2rec('b.csv')
>>> a
rec.array([(datetime.date(2011, 7, 25), 91), (datetime.date(2011, 7, 26),
118)],
      dtype=[('date', '|O8'), ('count', '<i8')])
>>> b
rec.array([('foo', 1233), ('bar', 100)],
      dtype=[('name', '|S3'), ('count', '<i8')])


>>> np.array(a.tolist()).tolist()
[[datetime.date(2011, 7, 25), 91], [datetime.date(2011, 7, 26), 118]]
>>> np.array(b.tolist()).tolist()
[['foo', '1233'], ['bar', '100']]


The odd case is, 1233 becomes a string '1233' in the second command.  But
91 is still a number 91.

Why would this happen?  What's the correct way to do this conversion?

Thanks.

-uris-
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to