ersa_utils.py
def load_file(file_name):
    """
    Read data file of given path, use numpy.load if it is in .npy format,
    otherwise use pickle or imageio
    :param file_name: absolute path to the file
    :return: file data, or IOError if it cannot be read by either numpy or pickle or imageio
    """
    try:
        if file_name[-3:] == 'npy':
            data = np.load(file_name)
        elif file_name[-3:] == 'pkl' or file_name[-6:] == 'pickle':
            with open(file_name, 'rb') as f:
                data = pickle.load(f)
        elif file_name[-3:] == 'txt':
            with open(file_name, 'r') as f:
                data = f.readlines()
        else:
            data = imageio.imread(file_name)

        return data
    except Exception:  # so many things could go wrong, can't be more specific.
        raise IOError('Problem loading {}'.format(file_name))

    Read data file of given path, use numpy.load if it is in .npy format,
    otherwise use pickle or imageio
    :param file_name: absolute path to the file
    :return: file data, or IOError if it cannot be read by either numpy or pickle or imageio
    
Read data file of given path, use numpy.load if it is in .npy format,
otherwise use pickle or imageio
Read data file of given path use numpy . load if it is in . npy format otherwise use pickle or imageio
def load_file(file_name):
    try:
        if file_name[-3:] == 'npy':
            data = np.load(file_name)
        elif file_name[-3:] == 'pkl' or file_name[-6:] == 'pickle':
            with open(file_name, 'rb') as f:
                data = pickle.load(f)
        elif file_name[-3:] == 'txt':
            with open(file_name, 'r') as f:
                data = f.readlines()
        else:
            data = imageio.imread(file_name)
        return data
    except Exception:  
        raise IOError('Problem loading {}'.format(file_name))
def load_file ( file_name ) : try : if file_name [ - 3 : ] == 'npy' : data = np . load ( file_name ) elif file_name [ - 3 : ] == 'pkl' or file_name [ - 6 : ] == 'pickle' : with open ( file_name , 'rb' ) as f : data = pickle . load ( f ) elif file_name [ - 3 : ] == 'txt' : with open ( file_name , 'r' ) as f : data = f . readlines ( ) else : data = imageio . imread ( file_name ) return data except Exception : raise IOError ( 'Problem loading {}' . format ( file_name ) )
Read data file of given path, use numpy.load if it is in .npy format,
otherwise use pickle or imageio
Read data file of given path use numpy . load if it is in . npy format otherwise use pickle or imageio
"""
    Read data file of given path, use numpy.load if it is in .npy format,
    otherwise use pickle or imageio
    :param file_name: absolute path to the file
    :return: file data, or IOError if it cannot be read by either numpy or pickle or imageio
    """ # so many things could go wrong, can't be more specific.
file data, or IOError if it cannot be read by either numpy or pickle or imageio
file data or IOError if it cannot be read by either numpy or pickle or imageio
file_name
absolute path to the file
absolute path to the file