PyTables/PyTables — pull request #400 by alimuldal (2014-11-11 14:03:36+00:00)
Title: pttree - a script for printing PyTables HDF5 file contents as a pretty ASCII tree

I often want to get a quick overview of the contents of an HDF5 file, especially in order to know which items are taking up a lot of disk space. I find the output of `ptdump` much too verbose for this, and it can't tell me how much disk space each array/table is taking up. GUI-based tools like `vitables` provide some of the functionality I'm looking for, but I usually work on headless servers so these aren't always an option.

For these reasons I've made a new script called `pttree`, which prints a summary of the contents of an HDF5 file as an ASCII tree (similar to the output of the Unix `tree` utility):

```
$ pttree ~/local_data/fclones/130222/13022204/13022204.hdf5:/ -L 2

------------------------------------------------------------

/ (RootGroup)
+--refgroups (Group)
| +--grdepth_clip1 (Group)
| | ... 1225 items, mem=4.1GiB, disk=3.6GiB [37.2%]
| +--grdepth_clip2 (Group)
| | ... 1069 items, mem=4.1GiB, disk=3.5GiB [36.7%]
| +--grdepth_clip1_dummy (Group)
| | ... 867 items, mem=1.3GiB, disk=1.2GiB [12.1%]
| `--grdepth_clip2_dummy (Group)
| ... 831 items, mem=1.3GiB, disk=1.1GiB [12.0%]
+--stacks (Group)
| +--grstack (Array)
| | ... 1 items, mem=134.0MiB, disk=134.0MiB [ 1.4%]
| +--r001 (CArray)
| | ... 1 items, mem=31.5MiB, disk=18.4MiB [ 0.2%]
| `--r002 (CArray)
| ... 1 items, mem=47.0MiB, disk=15.3MiB [ 0.2%]
+--pairs (Table)
| mem=28.6MiB, disk=28.7MiB [ 0.3%]
+--cells (Table)
| mem=56.9KiB, disk=18.4KiB [ 0.0%]
+--fileinfo (Group)
| +--r001 (Group)
| | ... 36 items, mem=363.0B, disk=363.0B [ 0.0%]
| +--grstack (Group)
| | ... 40 items, mem=327.0B, disk=327.0B [ 0.0%]
| `--r002 (Group)
| ... 37 items, mem=326.0B, disk=326.0B [ 0.0%]
`--refstackind (Array)
mem=8.0B, disk=8.0B [ 0.0%]

------------------------------------------------------------
Total branch items: 4111
Total branch size: 11.0GiB in memory, 9.5GiB on disk
Mean compression ratio: 0.87
HDF5 file size: 10.0GiB
------------------------------------------------------------
```
The tree can be rooted at any node within the file, and can be printed to any arbitrary depth. The nodes can be ordered by size or name, and there are also options for printing the shape and compression status of individual tables/arrays within the tree.