-1

When I try to open .h5 file, it shows the following error

Traceback (most recent call last):
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\IPython\core\interactiveshell.py", line 2869, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-10-524e5789c66b>", line 6, in <module>
    f = h5py.File(filename, 'r+')
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\h5py\_hl\files.py", line 394, in __init__
    swmr=swmr)
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\h5py\_hl\files.py", line 172, in make_fid
    fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5f.pyx", line 85, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = '28ggv-016.h5.h5', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2)

Code I used:

import h5py
import numpy as np
import pandas as pd
filename = '28ggv-016.h5'
f = h5py.File(filename, 'r')
DirtyBit
  • 16,613
  • 4
  • 34
  • 55
Mari
  • 698
  • 1
  • 8
  • 27
  • 3
    have you tried using the full path to the file ? –  Mar 06 '19 at 10:24
  • Probably could not find the file. Give the full path, double check it exists where you think it should. – DirtyBit Mar 06 '19 at 10:28
  • Yes when i give the absolute path it reads !!!! @reportgunner But what is the reason, for not opening directly ? – Mari Mar 06 '19 at 10:30
  • 1
    you are most likely executing the script from a directory different than the `.h5` file –  Mar 06 '19 at 10:31
  • @ponraj.rajesh did the answer posted below helped? If it did you may accept it: https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – DirtyBit Mar 18 '19 at 10:53

1 Answers1

3

Ctrl + Shift + C to copy the complete path of the file and paste it inside your filename:

import h5py
import numpy as np
import pandas as pd
filename = 'dir:\your\path\to\the\file\28ggv-016.h5'
f = h5py.File(filename, 'r')
DirtyBit
  • 16,613
  • 4
  • 34
  • 55