If you just need to attach the XML file to the hdf5 file, you can add it as an attribute to the hdf5 file.
xmlfh = open('morphology.xml', 'rb') h5f.attrs['xml'] = xmlfh.read()
You can access the xml file, for example:
h5f.attrs['xml']
Please note that you cannot store attributes larger than 64 KB, you may want to compress the file before connecting. You can look at library compression in the standard Python library.
However, this does not make the information in the XML file very accessible. If you want to associate the metadata of each dataset with some metadata in the XML file, you can map them as you need using an XML library such as lxml . You can also add each XML data field to a separate attribute so that you can query the data sets for the XML field, it all depends on what you have in the XML file. Try to think about how you want to get the data later.
You can also create groups for each xml file with its data sets and put it all in one hdf5 file. I do not know how large the files you manage are YMMV.
source share