From: Francesc A. <fa...@ca...> - 2005-12-09 18:35:26
|
Hi Stefan, A Divendres 09 Desembre 2005 18:49, Stefan Kuzminski va escriure: > If I run the following code.. > > fp =3D openFile( 'tmp.h5', 'w' ) > desc =3D { 'a' : StringCol( length=3D8 ) } > table =3D fp.createTable( fp.root, 'foobar', desc ) > table.append( [['spam'],['']] ) > table.flush() > print table.read() > > it prints out > > NestedRecArray[ > ('spam'), > (' ') > ] > > Note that the second string in the append was a empty string, but what > is read and printed is a single space, is there a reason for this or a > way around it? Yes, there is a reason for this, not exactly related with PyTables but with the interaction of numarray and the FITS library. You can read more about this issue in: http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1304615&group_= id=3D1369&atid=3D450446 A workaround is to patch the numarray sources in your local installation: =2D-- /usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/= numarray/records.py.orig=20 2005-12-09 19:22:46.870629670 +0100 +++ /usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/nu= marray/records.py =20 2005-12-09 19:23:01.023381709 +0100 @@ -101,7 +101,7 @@ arrlist[col] =3D num.array(tmp) except: try: =2D arrlist[col] =3D chararray.array(tmp) + arrlist[col] =3D chararray.array(tmp, padc=3D'\x00') except: raise ValueError, "inconsistent data at row %d,field %d" %= =20 (row, col) _array =3D fromarrays(arrlist, formats=3Dformats, shape=3D_shape, name= s=3Dnames, Perhaps if users start to request a more 'reasonable' behaviour for the numarray.strings, we can lobby for a better solution in numarray.=20 Sorry about that, =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |