Use of hdf5 library in Python with ctypes
<p>I would like to use <code>hdf5</code> library directly from <code>Python</code> with <code>ctypes</code>. I know that <code>h5py</code> and <code>PyTables</code> do the job perfectly. The reason I want to do this: I need to work with <code>hdf5</code> files with a <code>Python</code> interpreter where I can not install any package.</p>

<p>I am looking for an example that creates a file and write a list of doubles. </p>

<p>So far, I have written</p>

<pre><code>from ctypes import *
hdf5Lib=r'/usr/local/lib/libhdf5.dylib'
lib=cdll.LoadLibrary(hdf5Lib)
major = c_uint()
minor = c_uint()
release = c_uint()
lib.H5get_libversion(byref(major), byref(minor), byref(release))
H5Fopen=lib.H5Fopen
...
</code></pre>

<p>I don't know how to call H5Fopen. Should I use <code>H5Fopen.argtypes</code>? Any advice is welcome is to open the hdf5 file, create a dataset that of doubles, write the data and close the file.</p>

<p>I have followed the advices given, and I have written a small C program to discover the value of different macros. </p>

<pre><code>#include "hdf5.h"
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main (void)
{
    printf("H5F_ACC_TRUNC  = %u\n",H5F_ACC_TRUNC);
    printf("H5P_DEFAULT    = %u\n",H5P_DEFAULT);
    printf("H5T_STD_I32LE  = %u\n",H5T_STD_I32LE);
    printf("H5T_STD_I32BE  = %i\n",H5T_STD_I32BE);
    printf("H5T_NATIVE_INT = %u\n",H5T_NATIVE_INT);
    printf("H5S_ALL        = %u\n",H5S_ALL);
    return 0;
}
</code></pre>

<p>which produce</p>

<pre><code>H5F_ACC_TRUNC  = 2
H5P_DEFAULT    = 0
H5T_STD_I32LE  = 50331712
H5T_STD_I32BE  = 50331713
H5T_NATIVE_INT = 50331660
H5S_ALL        = 0
</code></pre>

python ctypes hdf5