Hi,I noticed that if I open an erroneous file (eg: empty), then it seems not possible to completely close it and reopen the same path, even if a valid file was created in the meanwhile.
The error is:ValueError: The file 'touch.h5' is already opened. Please close it before reopening in write mode.
You find a complete example attached. Regards, daniele
#!/usr/bin/python import tables from traceback import print_exc import os print '|| Creating a correct tables file, named ok.h5:' t=tables.openFile('ok.h5',mode='w') print 'Created:',t t.close() # Touch a file print '|| Creating an empty file, named touch.h5:' f=open('touch.h5','w') f.write('ciao') f.close() print 'done' print '|| Opening the empty file as if it was hdf5...' try: t=tables.openFile('touch.h5',mode='r') print t except: print '|| Error while opening empty file as if it was hdf5:' print_exc() print '|| Trying to close the erroneous file' try: t.close() print '|| File touch.h5 is now closed' except: print '|| Also closing that file causes an exception.' print_exc() print '|| Rename the correct hdf5 file as the old empty file path' os.remove('touch.h5') os.rename('ok.h5', 'touch.h5') print '|| Try to open the correct hdf5 file, now renamed as the old empty file:' t=tables.openFile('touch.h5',mode='w') try: print t except: print '|| Write mode should overwrite any existing file, instead something of the old empty file remains in the hdf library...' print_exc() print 'Done'
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users