Hi Francesc:
Thanks for your reply. It is a big relief to know that the two
projects are designed to work with one another. Below, I've included:
1) The pytables code to generate the hdf5 file, with one record in the
/streams/time table
2) The c++ code which simply opens the file and appends two more records.
After these are both run, the /streams/time table should have 3
records, but seems to only have two...which are the record pytables
wrote and the second record added by hdf5. I checked this using the
hdfview program and h5dump.
I've run this on two platforms:
1) pytables version 2.0.3 on 32 bit ubuntu linux, and the c++ used
hdf5 version 1.8.2
2) pytables version 2.0.3 on 64 bit ubuntu linux, and the c++ used
bdf5 version 1.8.1
And the versions of hdf5 for the C++ were compiled with --enable-parallel
Thank you very much for your help!
Milad
************** PYTABLES CODE **************
import tables
class TimeStreamInfo(tables.IsDescription):
cycle = tables.Int32Col()
dt = tables.Float64Col()
time = tables.Float64Col()
h5file = tables.openFile("simple-brick.h5", mode = "w")
group = h5file.createGroup("/","streams")
stream = h5file.createTable(group, 'time', TimeStreamInfo, "Time Information" )
info = stream.row
info['cycle'] = 0
info['dt'] = 0.1
info['time'] = 0.0
info.append()
stream.flush()
************ C++ CODE ************
#include <cassert>
using namespace std;
#include <hdf5.h>
#include <hdf5_hl.h>
struct TimeStreamData
{
int cycle;
double dt;
double time;
};
size_t offsets[3] = { HOFFSET(TimeStreamData, cycle),
HOFFSET(TimeStreamData, dt),
HOFFSET(TimeStreamData, time) };
size_t sizes[3] = { sizeof(int),
sizeof(double),
sizeof(double) };
int main()
{
hid_t file_id;
hid_t group_id;
herr_t err;
// Open the file:
file_id = H5Fopen("simple-brick.h5", H5F_ACC_RDWR, H5P_DEFAULT);
assert(file_id >= 0);
// Open the /streams group:
group_id = H5Gopen(file_id, "streams", H5P_DEFAULT);
assert(group_id >= 0);
// Append data to the table:
TimeStreamData data;
data.cycle = 1;
data.dt = 0.1;
data.time = 0.1;
err = H5TBappend_records(group_id, "time", 1,
sizeof(TimeStreamData), offsets, sizes, &data);
assert(!err);
data.cycle = 2;
data.dt = 0.1;
data.time = 0.2;
err = H5TBappend_records(group_id, "time", 1,
sizeof(TimeStreamData), offsets, sizes, &data);
assert(!err);
H5Gclose(group_id);
H5Fclose(file_id);
return 0;
}
On Fri, Nov 14, 2008 at 2:37 AM, Francesc Alted <[EMAIL PROTECTED]> wrote:
> Dear Milad,
>
> A Friday 14 November 2008, Milad Fatenejad escrigué:
>> Hello:
>>
>> I have been using pytables to create HDF5 files which are then read
>> in by another code, written in C++ which uses the 1.8.1 version of
>> the HDF5 library. Everything was going well until I made a table with
>> 1 record in pytables, then appended to the table in the C++ code
>> using the H5TB interface. No matter how many records I appended in
>> C++, only 2 records would actually be stored - the original one I
>> made with pytables and the last record I appended in C++. If I create
>> the table in C++, I can append to it without problems...
>>
>> My main question is: Is it OK to write/modify HDF5 tables made with
>> pytables in C/C++? And to what extent are HDF5 files generated in
>> pytables usable by other HDF5 tools that don't use pytables?
>
> Mmh, tables made with PyTables should be exactly the same than those
> created with the H5TB interface (in fact, PyTables borrowed the format
> from H5TB), so they should be completely compatible. Can you send the
> C++ code where you are adding the new records?
>
>> I have a feeling that there can be incompatibilities because tables
>> generated by pytables have a VERSION attribute set to 2.6, while
>> those generated in C/C++ with hdf5 v1.8.1 have a VERSION attribute
>> set to 2.0 (although I am not sure exactly what this version number
>> means...)
>
> This is metadata information that is only used internally in PyTables
> mainly for making distinction of the several kinds of indexes
> (available in the Pro version). So, I'd say that having different
> VERSION values should not be a problem for what you are trying to do.
>
> Cheers,
>
> --
> Francesc Alted
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users