

def parse_transactions(type, file):
    file = _null_byte_line_filter(codecs.iterdecode(file, 'utf_8_sig'))
    parsed = None
    if (type == 'FRANO'):
        reader = csv.reader(file)
        _verify_transaction_file_header(reader, FRANO_TRANSACTION_EXPORT_HEADER)
        parsed = parse_frano_transactions(reader)
    elif (type == 'GOOGLE'):
        reader = csv.reader(codecs.iterdecode(file, 'utf_8_sig'))
        _verify_transaction_file_header(reader, GOOGLE_TRANSACTION_EXPORT_HEADER)
        parsed = parse_google_transactions(reader)
    elif (type == 'AMERITRADE'):
        reader = csv.reader(file)
        _verify_transaction_file_header(reader, AMERITRADE_TRANSACTION_EXPORT_HEADER)
        parsed = parse_ameritrade_transactions(reader)
    elif (type == 'ZECCO'):
        reader = csv.reader(file)
        _verify_transaction_file_header(reader, ZECCO_TRANSACTION_EXPORT_HEADER)
        parsed = parse_zecco_transactions(reader)
    elif (type == 'SCOTTRADE'):
        reader = csv.reader(_null_byte_line_filter(file))
        _verify_transaction_file_header(reader, SCOTTRADE_TRANSACTION_EXPORT_HEADER)
        parsed = parse_scottrade_transactions(reader)
    elif (type == 'CHARLES'):
        reader = csv.reader(_null_byte_line_filter(file))
        reader.next()
        _verify_transaction_file_header(reader, CHARLES_TRANSACTION_EXPORT_HEADER)
        parsed = parse_charles_transactions(reader)
    elif (type == 'FIDELITY'):
        reader = csv.reader(file)
        for x in range(3):
            reader.next()
        _verify_transaction_file_header(reader, FIDELITY_TRANSACTION_EXPORT_HEADER)
        parsed = parse_fidelity_transactions(reader)
    elif (type == 'MERCER_401'):
        reader = csv.reader(file)
        _verify_transaction_file_header(reader, MERCER_401_TRANSACTION_EXPORT_HEADER)
        parsed = parse_mercer_401_transactions(reader)
    transactions = []
    for row in parsed:
        transaction = Transaction()
        transaction.as_of_date = row['date']
        transaction.type = row['type']
        transaction.symbol = row['symbol'].upper()
        transaction.quantity = row['quantity']
        transaction.price = row['price']
        transaction.total = row['total']
        transaction.linked_symbol = row.get('linked_symbol', None)
        transactions.append(transaction)
    return transactions

dataset/ETHPy150Open fxdemolisher/frano/frano/transactions/models.py parse_transactions/original