Hello James,
A Dilluns 20 Febrer 2006 22:26, vàreu escriure:
> I am embedding a binary file into an HDF5 file using Java. Basically,
> the Java code creates a scalar dataset of type Integer and writes an
> array of bytes to it.
> How might I use Pytables to extract this so that the file can be
> re-created on disk?
> Here is basically what I'm doing on the Java side:
>
> byte[] data = {};
> int fileSize = 0;
> File inputFile = new File(dataFilePath);
> FileInputStream in = new FileInputStream(inputFile);
> fileSize = (int)inputFile.length();
> data = new byte[fileSize];
> in.read(data);
> in.close();
> Datatype dtype = h5File.createDatatype(Datatype.CLASS_INTEGER, 1,
> Datatype.NATIVE,
> Datatype.NATIVE);
> Dataset dataset = h5File.createScalarDS(datasetName, tmpGroup,
> dtype, size, size, null,
> 0, data);
>
> Any help would be greatly appreciated.
Well, there are many ways to do that. A simple one would be:
buff = fileh.root.getNode('your_node_path').read()
buff.tofile('the_pathname_of_your_binary_file')
You can even save the file name of your binary file in an HDF5
attribute and use it afterward in PyTables to re-create it.
HTH,
--
Francesc Altet
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users