def read(file, system):
    """read PSS/E RAW file v32 format"""

    blocks = [
        'bus', 'load', 'fshunt', 'gen', 'branch', 'transf', 'area',
        'twotermdc', 'vscdc', 'impedcorr', 'mtdc', 'msline', 'zone',
        'interarea', 'owner', 'facts', 'swshunt', 'gne', 'Q'
    ]
    nol = [1, 1, 1, 1, 1, 4, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0]
    rawd = re.compile(r'rawd\d\d')

    retval = True
    version = 0
    b = 0  # current block index
    raw = {}
    for item in blocks:
        raw[item] = []

    data = []
    mdata = []  # multi-line data
    mline = 0  # line counter for multi-line models

    # parse file into raw with to_number conversions
    fid = open(file, 'r')
    for num, line in enumerate(fid.readlines()):
        line = line.strip()
        if num == 0:  # get basemva and frequency
            data = line.split('/')[0]
            data = data.split(',')

            mva = float(data[1])
            system.config.mva = mva
            system.config.freq = float(data[5])

            # get raw file version
            version = int(data[2])
            if not version:
                version = int(rawd.search(line).group(0).strip('rawd'))
            logger.debug('PSSE raw version {} detected'.format(version))

            if version < 32 or version > 33:
                logger.warning(
                    'RAW file version is not 32 or 33. Error may occur.')
            continue

        elif num == 1:  # store the case info line
            logger.info(line)
            continue
        elif num == 2:
            continue
        elif num >= 3:
            if line[0:2] == '0 ' or line[0:3] == ' 0 ':  # end of block
                b += 1
                continue
            elif line[0] == 'Q':  # end of file
                break
            data = line.split(',')

        data = [to_number(item) for item in data]
        mdata.append(data)
        mline += 1
        nol = get_nol(b, mdata)

        if mline >= nol:
            if nol == 1:
                mdata = mdata[0]
            raw[blocks[b]].append(mdata)
            mdata = []
            mline = 0
    fid.close()

    # add device elements to system
    sw = {}  # idx:a0
    max_bus = []
    for data in raw['bus']:
        """version 32:
          0,   1,      2,     3,    4,   5,  6,   7,  8
          ID, NAME, BasekV, Type, Area Zone Owner Vm, Va
        """
        idx = data[0]
        max_bus.append(idx)
        ty = data[3]
        a0 = data[8] * deg2rad

        if ty == 3:
            sw[idx] = a0
        param = {
            'idx': idx,
            'name': data[1],
            'Vn': data[2],
            'voltage': data[7],
            'angle': a0,
            'area': data[4],
            'zone': data[5],
            'owner': data[6],
        }
        system.Bus.elem_add(**param)
    max_bus = max(max_bus)
    for data in raw['load']:
        """version 32:
          0,  1,      2,    3,    4,    5,    6,      7,   8,  9, 10,   11
        Bus, Id, Status, Area, Zone, PL(MW), QL (MW), IP, IQ, YP, YQ, OWNER
        """
        bus = data[0]
        vn = system.Bus.get_field('Vn', bus)
        voltage = system.Bus.get_field('voltage', bus)
        param = {
            'bus': bus,
            'Vn': vn,
            'Sn': mva,
            'p': (data[5] + data[7] * voltage + data[9] * voltage**2) / mva,
            'q': (data[6] + data[8] * voltage - data[10] * voltage**2) / mva,
            'owner': data[11],
        }
        system.PQ.elem_add(**param)

    for data in raw['fshunt']:
        """
        0,    1,      2,      3,      4
        Bus, name, Status, g (MW), b (Mvar)
        """
        bus = data[0]
        vn = system.Bus.get_field('Vn', bus)
        param = {
            'bus': bus,
            'Vn': vn,
            'u': data[2],
            'Sn': mva,
            'g': data[3] / mva,
            'b': data[4] / mva,
        }
        system.Shunt.elem_add(**param)

    gen_idx = 0
    for data in raw['gen']:
        """
         0, 1, 2, 3, 4, 5, 6, 7,    8,   9,10,11, 12, 13, 14,   15, 16,17,18,19
         I,ID,PG,QG,QT,QB,VS,IREG,MBASE,ZR,ZX,RT,XT,GTAP,STAT,RMPCT,PT,PB,O1,F1
        """
        bus = data[0]
        vn = system.Bus.get_field('Vn', bus)
        gen_mva = data[8]  # unused yet
        gen_idx += 1
        status = data[14]
        param = {
            'Sn': gen_mva,
            'Vn': vn,
            'u': status,
            'idx': gen_idx,
            'bus': bus,
            'pg': status * data[2] / mva,
            'qg': status * data[3] / mva,
            'qmax': data[4] / mva,
            'qmin': data[5] / mva,
            'v0': data[6],
            'ra': data[9],  # ra  armature resistance
            'xs': data[10],  # xs synchronous reactance
            'pmax': data[16] / mva,
            'pmin': data[17] / mva,
        }
        if data[0] in sw.keys():
            param.update({
                'a0': sw[data[0]],
            })
            system.SW.elem_add(**param)
        else:
            system.PV.elem_add(**param)

    for data in raw['branch']:
        """
        I,J,CKT,R,X,B,RATEA,RATEB,RATEC,GI,BI,GJ,BJ,ST,LEN,O1,F1,...,O4,F4
        """
        param = {
            'bus1': data[0],
            'bus2': data[1],
            'r': data[3],
            'x': data[4],
            'b': data[5],
            'rate_a': data[6],
            'Vn': system.Bus.get_field('Vn', data[0]),
            'Vn2': system.Bus.get_field('Vn', data[1]),
        }
        system.Line.elem_add(**param)

    xf_3_count = 1
    for data in raw['transf']:
        if len(data) == 4:
            """
            I,J,K,CKT,CW,CZ,CM,MAG1,MAG2,NMETR,'NAME',STAT,O1,F1,...,O4,F4
            R1-2,X1-2,SBASE1-2
            WINDV1,NOMV1,ANG1,RATA1,RATB1,RATC1,COD1,CONT1,RMA1,RMI1,VMA1,VMI1,NTP1,TAB1,CR1,CX1
            WINDV2,NOMV2
            """

            tap = data[2][0]
            phi = data[2][2]

            if tap == 1 and phi == 0:
                trasf = False
            else:
                trasf = True
            param = {
                'trasf': trasf,
                'bus1': data[0][0],
                'bus2': data[0][1],
                'u': data[0][11],
                'b': data[0][8],
                'r': data[1][0],
                'x': data[1][1],
                'tap': tap,
                'phi': phi,
                'rate_a': data[2][3],
                'Vn': system.Bus.get_field('Vn', data[0][0]),
                'Vn2': system.Bus.get_field('Vn', data[0][1]),
            }
            system.Line.elem_add(**param)
        else:
            """
            I, J, K, CKT, CW, CZ, CM, MAG1, MAG2, NMETR, 'NAME', STAT, Ol, Fl,...,o4, F4
            R1—2, X1—2, SBASE1—2, R2—3, X2—3, SBASE2—3, R3—1, X3—1, SBASE3—1, VMSTAR, ANSTAR
            WINDV1, NOMV1, ANG1, RATA1, BATB1, RATC1, COD1, CONT1, RMA1, RMI1, VMA1, VMI1, NTP1, TAB1, CR1, CX1
            WINDV2, NOMV2, ANG2, RATA2, BATB2, RATC2, COD2, CONT2, RMA2, RMI2, VMA2, VMI2, NTP2, TAB2, CR2, CX2
            WINDV3, NOMV3, ANG3, RATA3, BATB3, RATC3, COD3, CONT3, RMA3, RMI3, VMA3, VMI3, NTP3, TAB3, CR3, CX3
            """
            param = {
                'idx': max_bus+xf_3_count,
                'name': '_'.join(str(data[0][:3])),
                'Vn': system.Bus.get_field('Vn', data[0][0]),
                'voltage': data[1][-2],
                'angle': data[1][-1]/180*3.14
            }
            system.Bus.elem_add(**param)

            r = []
            x = []
            r.append((data[1][0] + data[1][6] - data[1][3])/2)
            r.append((data[1][3] + data[1][0] - data[1][6])/2)
            r.append((data[1][6] + data[1][3] - data[1][0])/2)
            x.append((data[1][1] + data[1][7] - data[1][4])/2)
            x.append((data[1][4] + data[1][1] - data[1][7])/2)
            x.append((data[1][7] + data[1][4] - data[1][1])/2)
            for i in range(0, 3):
                param = {
                    'trasf': True,
                    'bus1': data[0][i],
                    'bus2': max_bus+xf_3_count,
                    'u': data[0][11],
                    'b': data[0][8],
                    'r': r[i],
                    'x': x[i],
                    'tap': data[2+i][0],
                    'phi': data[2+i][2],
                    'rate_a': data[2+i][3],
                    'Vn': system.Bus.get_field('Vn', data[0][i]),
                    'Vn2': system.Bus.get_field('Vn', data[0][0]),
                }
                system.Line.elem_add(**param)
            xf_3_count += 1

    for data in raw['swshunt']:
        # I, MODSW, ADJM, STAT, VSWHI, VSWLO, SWREM, RMPCT, ’RMIDNT’,
        # BINIT, N1, B1, N2, B2, ... N8, B8
        bus = data[0]
        vn = system.Bus.get_field('Vn', bus)
        param = {
            'bus': bus,
            'Vn': vn,
            'Sn': mva,
            'u': data[3],
            'b': data[9] / mva,
        }
        system.Shunt.elem_add(**param)

    for data in raw['area']:
        """ID, ISW, PDES, PTOL, ARNAME"""
        param = {
            'idx': data[0],
            'isw': data[1],
            'pdes': data[2],
            'ptol': data[3],
            'name': data[4],
        }
        system.Area.elem_add(**param)

    for data in raw['zone']:
        """ID, NAME"""
        param = {
            'idx': data[0],
            'name': data[1],
        }
        system.Zone.elem_add(**param)

    return retval