示例#1
0
def getMintTransactions(accounts):

    try:
        mint = Mint(email = accounts[0], password = accounts[1])
        mint.initiate_account_refresh()
        df = mint.get_transactions()
        df.to_csv('CSVs/' + accounts[2])

        print accounts[0] + " accepted correctly."

        return df
    except:
        print accounts[0] + " was not accepted."
        return pd.DataFrame()
示例#2
0
def mintImport():

    import instance

    mintAccounts = instance.mintaccounts()

    if mintacct:
        for key, accounts in mintAccounts.iteritems():
            try:
                mint = Mint(email = accounts[0], password = accounts[1])
                mint.initiate_account_refresh()
                df = mint.get_transactions()
                df.to_csv('CSVs/' + accounts[2])
                print accounts[0] + " accepted correctly."
            except:
                print accounts[0] + " was not accepted."
    else:
        print "Mint accounts intentionally not imported. Change 'mintacct' variable to 'True'."

    df = pd.DataFrame()
    columns = ['id','transdate','description','originaldescription','amount','debitcredit','category','accountname','labels','notes']

    for key, accounts in mintAccounts.iteritems():
        df2 = pd.read_csv('CSVs/' + accounts[2], parse_dates = ['Date'])
        df2.columns = columns
        if df.empty:
            df = df2
        else:
            df = df.append(df2)

    df.drop('id',axis=1,inplace=True)

    df.loc[df['debitcredit'] == 'debit', ['amount']] *= -1     # reverses sign for 'debit' transactions
    df.reset_index(level=0, inplace=True)
    df.columns = ['id','transdate','description','originaldescription','amount','debitcredit','category','accountname','labels','notes']
    df = df[['id','transdate','description','amount','category','accountname']]

    return df