Filtering accounts using AcctFilter
Hi, I'm trying to list accounts, but want to exclude categories, investment accounts. etc. Basically I'm just trying to isolate bank accounts and credit card accounts which I downloaded financial transactions for. I think I can use AcctFilter, but I'm really unclear how to use this in python.
I'm using:
accounts = AccountIterator(moneydance.getRootAccount())
accounts = filter(lambda x: x.getAccountType().toString() == "INCOME" or x.getAccountType().toString() == "EXPENSE", accounts)
this gives me the transactions I'm looking for but the accounts I get are bank accounts, categories etc. I'd like to filter down to just the bank and credit card account types...
How would I do this?
Thanks!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by davidcullen on 26 Apr, 2021 07:30 AM
I am using instead:
because I also use:but I think that my ACCOUNTS and your accounts are identical.
I have put various RentalPropertyAgent etc in the Comments field of various Accounts and Categories, and then filter them by:
I'm not sure if this way is best, but it seems to work for me.
2 Posted by Stuart Beesley ... on 26 Apr, 2021 07:58 AM
This code should get you started:
3 Posted by davidcullen on 27 Apr, 2021 04:12 AM
Stuart: Your code above works perfectly (as I expected).
and also pass a group string to your filter, but I cannot see how to do this.However, i want to change your if statement to:
I'm currently getting:
using an ordinary python function on ACCOUNTS.
I'm not sure whether this is best, or if your filter can do the same (and better).
Please excuse my ignorance - I only have a little knowledge of java/jython.
4 Posted by Stuart Beesley ... on 27 Apr, 2021 04:59 AM
another example to assist:
FYI - at this point this is pure Python (not Java)....
5 Posted by davidcullen on 27 Apr, 2021 05:29 AM
Stuart,
Thanks very much. I have learned a lot!
A final question: is it better practice (and, if so, why) to use your filter approach or my [x for x in ACCOUNTS if group in x.comment] ?
6 Posted by Stuart Beesley ... on 27 Apr, 2021 05:47 AM
Not better, just different. Why not time each option and see? I would suggest that for 1 simple filter yours is just fine, but for a more complex filter then AcctFilter would be easier to code...
7 Posted by davidcullen on 27 Apr, 2021 06:34 AM
Stuart, Sorry to hassle you, but I have been going around in circles.
and want to query like:I'm trying to adapt your code to work with TxnSearch to get all txns between two dates. I have the all the txns:
but I cannot modify your examples to do this.
Can you help with your expertise?
8 Posted by Stuart Beesley ... on 27 Apr, 2021 07:00 AM
It's very difficult to guess what you are trying to do with snippets of code.... But this is a TxnSearch() code example:
If no good, please post full code you are trying to fix..... ?
9 Posted by davidcullen on 27 Apr, 2021 07:10 AM
Thanks!
10 Posted by Jim on 06 May, 2021 01:50 AM
Nice to see the healthy discussion. I got to hand it do you guys, you know your stuff!
System closed this discussion on 05 Aug, 2021 01:50 AM.