[SciPy-User] Populating a recarray from 0 size

Åsmund Hjulstad asmund.hjulstad@gmail....
Sun Aug 22 10:19:04 CDT 2010


2010/8/22 <josef.pktd@gmail.com>

> On Sat, Aug 21, 2010 at 9:18 PM, Sergi Pons Freixes <spons@utm.csic.es>
> wrote:
> > Hi everybody,
> >
> > I'm interested in populating a recarray a row at a time. I thought in
> using:
> >
> I don't know the answer, but it would be more efficient to correctly
> size the empty array, if you know the size, or to build up the array
> first as a list of tuples before converting to an array.
>
>
My approach in this kind of situation has been using pytables, creating an
empty table with a specific dtype, and then populating the table with the
append method. It seems very efficient, and quite convenient in situations
where I eventually will need to persist data to disk somehow.

Reading the table into an in memory recarray is then easily done using

data = h5file.root.datatable[:].view(numpy.recarray)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100822/64c2ce6b/attachment.html 


More information about the SciPy-User mailing list