[Numpy-discussion] how to build a series of arrays as I go?

Chris Withers chris@simplistix.co...
Mon Mar 17 10:46:24 CDT 2008

Hi All,

I'm using xlrd to read an excel workbook containing several columns of 
data as follows:

for r in range(1,sheet.nrows):
     date = \
     if date_cut_off and date < date_cut_off:
     for c in range(len(names)):
         name = names[c]
         cell = sheet.cell(r,c)
         if cell.ctype==xlrd.XL_CELL_EMPTY:
             value = -1
         elif cell.ctype==xlrd.XL_CELL_DATE:
             value = \
             value = cell.value

Two questions:

How can I build arrays as I go instead of lists?
(ie: the last line of the above snippet)

Once I've built arrays, how can I mask the empty cells?
(the above shows my hack-so-far of turning empty cells into -1 so I can 
use masked_where, but it would be greato build a masked array as I went, 
for efficiencies sake)

cheers for any help!


PS: Slightly pissed off at actually paying for the book only to be told 
it'll be 2 days before I can even read the online version, especially 
given the woefully inadequate state of the currently available free 
documentation :-(

Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk

More information about the Numpy-discussion mailing list