[Nexus] 2D character arrays in python binding?

Peterson, Peter F. (pf9) petersonpf at ornl.gov
Wed Jan 28 16:27:13 GMT 2009


Carlos,

Thank you for the question. I'm do not know the answer, but I do know that
the python binding has been in a state of flux for some time. Please specify
which version of the NeXus API you are using and the path within the
installation of the binding.

Peter Peterson


On 1/28/09 5:16 AM, "Carlos Pascual Izarra" <carlos.pascual at cells.es> wrote:

> Hello,
> After reading the lists and the python binding source code I am still not
> sure: is it possible to write 2D character arrays with the python binding?
> (other than manually converting the array to "uint8" and back when reading)
> 
> I've tried doing:
> 
> {{{
> filenames=['bar1','longerbar2','bar3']
> ...
> f.makedata('filenames','char',[3,32])
> f.opendata('filenames')
> f.putdata(filenames)
> ...
> }}}
> 
> but I get:
> {{{
> ValueError: Expected character data: foo.h5(entry/data/filenames)
> }}}
> 
> 
> I also tried putting the data row by row with putslab, replacing the putdata
> line with:
> {{{
> for i in range(3): f.putslab(filenames[i],[i,0],[1,32])
> }}}
> 
> In which case it does not raise an exception, but:
> a) it stores the data using dtype=uint8
> b) It stores garbage from contiguous memory (i.e. it does not pad the strings
> to fill the given shape)
> 
> Cheers,
> 
> Carlos Pascual
> 
> _______________________________________________
> NeXus mailing list
> NeXus at nexusformat.org
> http://lists.nexusformat.org/mailman/listinfo/nexus



More information about the NeXus mailing list