Dear pytables developers,
I have come across an oddity when I read pytables files written with
pytables 1.0 and read with pytables 2.0, and would like your opinion
on this.
What I consider a problem for my application is outlined below, and I
wanted to make sure that you are aware of this behaviour (it could be
a bug).
I create two h5 files using the following piece of code (once run with
pytables 1.3.2 and once with pytables 2.0.3)::
import numpy
import tables
print "Running with tables version %s" % tables.__version__
master_version = int(tables.__version__[0])
if master_version == 1:
fileName = 'tbl1.h5'
elif master_version == 2:
fileName = 'tbl2.h5'
else:
raise "Impossible"
h5f = tables.openFile(fileName, 'w')
if master_version == 1:
class Particle(tables.IsDescription):
name = tables.StringAtom(length=16)
idnumber = tables.Int64Atom()
else:
class Particle(tables.IsDescription):
name = tables.StringCol(16)
idnumber = tables.Int64Col()
my_table = h5f.createTable(h5f.root, 'test', Particle,
"watch the white space")
particle = my_table.row
particle['name']="A"
particle['idnumber']=01234
particle.append()
particle['name']="BCD"
particle['idnumber']=56789
particle.append()
my_table.flush
h5f.close()
Subsequently, I run the following piece of code with pytables 2.0::
for fileName,version in [('tbl1.h5','tables1.3.2'),
('tbl2.h5','tables2.0.3')]:
print "Reading the file written with %s" % version
h5f = tables.openFile(fileName)
for row in h5f.root.test.iterrows():
print row
h5f.close()
I get the following output::
Running with tables version 2.0.3
Reading the file written with tables1.3.2
(668, 'A ')
(56789, 'BCD ')
Reading the file written with tables2.0.3
(668, 'A')
(56789, 'BCD')
Note that the strings 'A' and 'BCD' are returned with whitespace
(filling up to the maximum length of the string) when reading the file
written with pytables 1.0 but not when reading the file written with
pytables 2.0.
I believe that the desired behaviour is not to return the white space.
Indeed, when running the reading code with pytables 1, I get the
'correct' output::
Running with tables version 1.3.2
Reading the file written with tables1.3.2
(668L, 'A')
(56789L, 'BCD')
Reading the file written with tables2.0.3
(668L, 'A')
(56789L, 'BCD')
I have put both tbl1.h5 and tbl2.h5 together with the testing code
shown above into a tar file located at http://www.soton.ac.uk/
~fangohr/geheim/versionbug.tar.gz
Is this a bug?
Many thanks,
Hans
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users