public static ReconcilableTransaction createTransactionsFromInput(String line) throws MalformedInputException {

        try{
            String[] values = line.split(",");

            // Remove white spaces from fields
            Long    id              = new Long(values[0]);
            String  name            = values[1].replaceAll("\\s", "");
            Double  amount          = new Double(values[2].replaceAll("\\s", ""));
            String  dateString      = values[3].replaceAll("\\s", "");
            boolean isCash          = Boolean.valueOf(values[4].replaceAll("\\s", ""));
            boolean isAtm           = Boolean.valueOf(values[5].replaceAll("\\s", ""));

            Date date = Date.valueOf(dateString);

            if(isAtm && !isCash){
                return new AtmWithdrawalTransaction(id, name, amount, date);

            } else if (isCash && !isAtm){
                return new CashPurchaseTransaction(id, name, amount, date);

            } else {
                throw new MalformedInputException(String.format("Input type is ambiguous (atm/cash): %s", line));
            }
        } catch (ArrayIndexOutOfBoundsException e){
            throw new MalformedInputException(String.format("Input has malformed records/lines: %s", line));
        }

    }