uvemas/ViTables

Not showing hierarchical keys

BrendanMartin opened this issue · 5 comments

I used pandas' store.put() to create a hierarchical key:
store.put('parent/child', dataframe)

But ViTables doesn't show the 'parent' key or the 'child' key.

I am able to store.select('parent/child') the data back out, and the store.keys() method shows it in there, so the data is definitely stored.

Am I doing something wrong?

I haven't tested it by myself but I don't think you're doing anything wrong. It seems to me that the problem is simply that ViTables' support of Panda is too primitive. It is work in progress, you know. Unfortunately I cannot work on ViTables since some time ago (I hope this situation will change in the future) so I cannot try to fix it. But if you can provide a PR I'll merge it.

This shouldn't be happening.

For instance, generating a new HDF wit this code:

df = pd.DataFrame({'a':[1,2], 'b':[3,4]})
df.to_hdf('t1.hdf', '/foo/bar')

... works fine. Respective HDFStore code work also fine:

with pd.HDFStore('t2.hdf')
    hs.put('/foo/bar', df)

But this creates an incomplete store:

hs = pd.HDFStore('t2.hdf')
hs.put('/foo/bar', df)

...which breaks ViiTables on opening, with this log-message:

ViTables 3.0.0
Copyright (c) 2008-2017 Vicent Mas.
All rights reserved.
2018-01-22 19:37:41,532 - vitables.utils - ERROR - Traceback (most recent call last):
  File "d:\work\vitables.git\vitables\h5db\dbdoc.py", line 109, in openH5File
    h5file = tables.open_file(self.filepath, self.mode)
tables.exceptions.HDF5ExtError: HDF5 error back trace

  File "D:\Build\HDF5\hdf5-1.10.1\src\H5F.c", line 586, in H5Fopen
    unable to open file
  File "D:\Build\HDF5\hdf5-1.10.1\src\H5Fint.c", line 1384, in H5F_open
    unable to read superblock
  File "D:\Build\HDF5\hdf5-1.10.1\src\H5Fsuper.c", line 530, in H5F__super_read
    truncated file: eof = 96, sblock->base_addr = 0, stored_eof = 2048

End of HDF5 error back trace

Unable to open/create file 'D:/Work/tmp/t1.hdf'

2018-01-22 19:37:41,547 - vitables.h5db.dbdoc - ERROR - Please, if you think it is a bug, report it to developers.
2018-01-22 19:37:41,547 - vitables - ERROR -   File "d:\work\vitables.git\vitables\vtapp.py", line 629, in fileOpen
    if self.gui.dbs_tree_model.openDBDoc(filepath, mode, position):
  File "d:\work\vitables.git\vitables\h5db\dbstreemodel.py", line 232, in openDBDoc
    root_node = rootgroupnode.RootGroupNode(self, db_doc, self.root)
  File "d:\work\vitables.git\vitables\h5db\rootgroupnode.py", line 65, in __init__
    self.node = data_source.get_node('/')
  File "d:\work\vitables.git\vitables\h5db\dbdoc.py", line 157, in get_node
    node = self.h5file.get_node(where)
'NoneType' object has no attribute 'get_node'

...which most likely seems unrelated to the pandas code,
correct @uvemas?

@BrendanMartin could it be that you forgot to close the store?

OMG! It's impossible to make mistakes when you are around :-) I've tested it and you're right @ankostis But I'm confused because @BrendanMartin doesn't mention any error message.

@uvemas I don't see any log messages. But now that I just tried it again, I can see my keys now. I'm not sure why I couldn't see it earlier.

Ok, I assume it was just an isolated misbehavior. I'm going to close the issue. Feel free to reopen it if the problem appears again. Thanks to @BrendanMartin for reporting and to @ankostis for the great help.