simple table sorting question

15 views
Skip to first unread message

Ken Walker

unread,
Oct 24, 2018, 4:59:32 PM10/24/18
to pytables-users
I'm trying to create a sort index on a simple table (no nested columns).
It looks simple enough in the documentation and emails in this forum.
I have a table at /RESULT/NODE/DISPLACEMENT
(or File.root.RESULT.NODE.DISPLACEMENT)
It has several columns. The one I'd like to sort is called DOMAIN.

I thought this code would do the job, but when I run, get a huge trace back.

h5_file = tables.open_file('test_sort.h5', mode='r+')
res_table=h5_file.root.RESULT.NODE.DISPLACEMENT
res_table.cols.DOMAIN.create_index()

What am I missing? I'm sure I've overlooked something simple.
Also is there way to sort on 2 columns? first on DOMAIN, then on another column?

Thanks,
-Ken

Francesc Alted

unread,
Oct 25, 2018, 3:23:20 AM10/25/18
to Ken Walker, pytable...@googlegroups.com
Hi Ken,

On Wed, Oct 24, 2018 at 10:59 PM Ken Walker <ken.c....@gmail.com> wrote:
I'm trying to create a sort index on a simple table (no nested columns).
It looks simple enough in the documentation and emails in this forum.
I have a table at /RESULT/NODE/DISPLACEMENT
(or File.root.RESULT.NODE.DISPLACEMENT)
It has several columns. The one I'd like to sort is called DOMAIN.

I thought this code would do the job, but when I run, get a huge trace back.

h5_file = tables.open_file('test_sort.h5', mode='r+')
res_table=h5_file.root.RESULT.NODE.DISPLACEMENT
res_table.cols.DOMAIN.create_index()

What am I missing? I'm sure I've overlooked something simple.

We need more information.  Could you send the backtrace (a self-contained example would also be nice)?  Also, filling a an issue in github would be good.
 
Also is there way to sort on 2 columns? first on DOMAIN, then on another column?

Sorry, but combined sorts are not implemented.

Cheers,
--
Francesc Alted

Ken Walker

unread,
Oct 25, 2018, 1:22:24 PM10/25/18
to pytables-users
Francesc,
Thanks for your response.
The HDF5 file is created by a 3rd party, so I don't have a self-contained example. Sorry.
The create_index() examples I saw looked pretty simple once a column handle was created.
I will work thru the tutorials, and see if I can answer my question or replicate my problem.
Thanks,
-Ken

Ken Walker

unread,
Oct 25, 2018, 2:23:06 PM10/25/18
to pytables-users
It didn't take long to figure out the source of my problems (although I haven't figured out the solution).
As I mentioned, the problematic HDF5 file is created by a 3rd party (probably written with HDFGroup C/C++ API).
I have a Pytables utility that creates a second file by copying parts of each table (using .read_where() from the first file/table and adding to the second file/table with .append()).
When I run code from my first post against my second HDF5 (Pytables) file, indexing works perfectly.
A review of the traceback when indexing the first file shows Pytables expects to find 1 or more attributes that are not in my original HDF5 file.

Francesc Alted

unread,
Oct 26, 2018, 3:23:36 AM10/26/18
to Ken Walker, pytable...@googlegroups.com
I see.  Yes, that makes sense.  Actually providing more support for tables that have not been created with PyTables would be a good thing (perhaps a good project for applying for a NumFOCUS grant?).

Francesc

--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-user...@googlegroups.com.
To post to this group, send email to pytable...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Francesc Alted
Reply all
Reply to author
Forward
0 new messages