How to use 'how to open mat file' in Python

Every line of 'how to open mat file' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
61def _open_file(file_like, appendmat):
62 ''' Open `file_like` and return as file-like object '''
63 if isinstance(file_like, basestring):
64 try:
65 return open(file_like, 'rb')
66 except IOError:
67 pass
68 if appendmat and not file_like.endswith('.mat'):
69 try:
70 return open(file_like + '.mat', 'rb')
71 except IOError:
72 pass
73 # search the python path - we'll remove this soon
74 full_name = find_mat_file(file_like, appendmat)
75 if full_name is None:
76 raise IOError("%s not found on the path."
77 % file_like)
78 return open(full_name, 'rb')
79 # not a string - maybe file-like object
80 try:
82 except AttributeError:
83 raise IOError('Reader needs file name or open file-like object')
84 return file_like

Related snippets