@staticmethod
    def load_txt(shape, file_in, dtype, fmtin):
        # file_in = open(self.__value,'r')
        # file_in = open(filename,'r')
        # nrow,ncol = self.shape
        nrow, ncol = shape
        npl, fmt, width, decimal = ArrayFormat.decode_fortran_descriptor(fmtin)
        data = np.zeros((nrow * ncol), dtype=dtype) + np.NaN
        d = 0
        if not hasattr(file_in, 'read'):
            file_in = open(file_in, 'r')
        while True:
            line = file_in.readline()
            if line in [None, ''] or d == nrow * ncol:
                break
            if npl == 'free':
                raw = line.strip('\n').split()
            else:
                # split line using number of values in the line
                rawlist = []
                istart = 0
                istop = width
                for i in range(npl):
                    txtval = line[istart:istop]
                    if txtval.strip() != '':
                        rawlist.append(txtval)
                    else:
                        break
                    istart = istop
                    istop += width
                raw = rawlist

            for a in raw:
                try:
                    data[d] = dtype(a)
                except:
                    raise Exception('Util2d:unable to cast value: ' +
                                    str(a) + ' to type:' + str(dtype))
                if d == (nrow * ncol) - 1:
                    assert len(data) == (nrow * ncol)
                    data.resize(nrow, ncol)
                    return data
                d += 1
                #        file_in.close()
        if np.isnan(np.sum(data)):
            raise Exception("Util2d.load_txt() error: np.NaN in data array")
        data.resize(nrow, ncol)
        return data
load a (possibly wrapped format) array from a file
dataset/ETHPy150Open modflowpy/flopy/flopy/utils/util_array.py/Util2d.load_txt