def fortran_read(fp, fmt):
    ''' read fortran formated file into array '''
    fw = fortran_parsefmt(fmt)
    res = []
    for line in fp:
        line.replace('D', 'E')  # replace fortran 77 double precision format
        tmp = []
        i = 0
        for rep, ftype, length in fw:
            for cnt in range(rep):
                field = line[i: i + length]
                i += length
                if ftype == 'F':
                    field = float(field)
                elif ftype == 'I':
                    field = int(field)
                elif ftype == 'A':
                    field = field
                else:
                    continue
                tmp.append(field)

        res.append(tmp)
    return res
 read fortran formated file into array 
aa.py