def fortran_readline(line, fmt):
    ''' read fortran formated file into array '''
    fw = fortran_parsefmt(fmt)
    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)

    return tmp
 read fortran formated file into array 
aa.py