[Nexus] 2D character arrays in python binding?
Carlos Pascual Izarra
carlos.pascual at cells.es
Wed Jan 28 10:16:29 GMT 2009
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
More information about the NeXus
mailing list