0

I'm running into a problem with the h5py module for python.

I'm trying to open a file in 'r+' mode and would like to change some characters within this file.

Whenever I overwrite the data, the character is deleted.

This is what I get:

>>> f = h5py.File(someFile, 'r+')
>>> f[someCharacters]
<HDF5 dataset "someChar": shape (83,), type "|S1">
>>> f[someCharacters][-7]
'l'
>>> f[someCharacters][-7] = 't'
>>> f.flush()
>>> f[someCharacters][-7]
''
>>> f.close()

Reopening the file doesn't help either...

>>> f = h5py.File(someFile, 'r+')
>>> f[someCharacters][-7]
''
>>> f.close()

I tried doing the same thing with a file that I created myself and that works just fine:

>>> f = h5py.File('./testFile.h5', 'r+')
>>> dset = f['myDSet']
>>> dset
<HDF5 dataset "myDSet": shape (100,), type "|S1">
>>> dset[5]
''
>>> dset[5] = 'r'
>>> dset[5]
'r'
>>> f.close()
>>> f = h5py.File('./testFile.h5', 'r+')
>>> f['myDSet'][5]
'r'
>>> f.close()

So I guess there's something special to the specific file 'someFile' that I'm trying to edit.

Thanks a lot for any suggestions or help!

nils
  • 43
  • 4
  • I think more information is needed. What's the output of `f[someCharacters]`? It should be something of the form `` – Yossarian Jan 23 '14 at 14:39
  • Thank you for your comment. I added some information to my post. `f[someCharacters]` is of type ``. – nils Jan 23 '14 at 18:05

0 Answers0