Faster way to search for existing FiTxnId?
This is what I put in and works but is pretty slow:
class IsMatch(TxnSearch):
def matchesAll(self):
return False
def matches(self, txn):
return txn.getFiTxnId(protocolId) == str(row)
results = book.getTransactionSet().getTransactions(IsMatch())
if (not results.getSize()):
pTxn.syncItem()
Anything faster? Like allows to search only a subset of transactions instead of all of them each time?
I suppose I could make all FiTxnId's ahead of time and match them all, then just not process the transactions that are already in MD. But not sure if faster way to search using MD API.
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 Stuart Beesley ... on 12 Dec, 2025 08:25 PM
I would call
ts.getTxnsForAccount()
(But under the covers it still does a whole txn scan to produce a subset)
Do you need to str(row)? Why not just == row or row.startswith()?
I would not call this per import record. I would probably prebuild a dictionary of all fi txn ids to txns before your main processing loop. Then you are scanning all txns just once.
2 Posted by Stuart Beesley ... on 12 Dec, 2025 08:26 PM
Or getTransactionsForAccount() is you want a TxnSet rather than a list.
3 Posted by mmd on 12 Dec, 2025 09:42 PM
Thanks. I feel bad posting to Fidelity thread as I worry bunch of people are subscribed and don't really want to see the nitty gritty. I could email you that's true I wish there was a DM functionality on the forum.
== row doesn't work at least for assigning it (since row is not a string)
I'll try to come up with something to check them all in one go
P.S. And I did take your advice into account re making the amounts into long values thank you.
On Fri, Dec 12, 2025 at 2:26 PM, Stuart Beesley < [email blocked] > wrote:
4 Posted by mmd on 12 Dec, 2025 10:01 PM
I made a new version that seems to be much faster, already added to my Google Drive link
dict_reader = csv.DictReader(file, fieldnames=firstRow)
if (online):
# Remove entries already in Moneydance
new_dict = {}
for row in dict_reader:
new_dict[str(row)] = row
class IsMatch(TxnSearch):
def matchesAll(self):
return False
def matches(self, txn):
if (txn.getFiTxnId(protocolId) in new_dict):
del new_dict[txn.getFiTxnId(protocolId)]
return True
else:
return False
results = book.getTransactionSet().getTransactions(IsMatch())
dict_reader = list(new_dict.values())
for row in dict_reader:
https://drive.google.com/file/d/1pYgdgEUYrGJtlm_-JI5PezfSphh2UzNW/view?usp=drive_link
On Fri, Dec 12, 2025 at 2:26 PM, Stuart Beesley < [email blocked] > wrote:
5 Posted by Stuart Beesley ... on 12 Dec, 2025 10:16 PM
There is a Slack forum for MD and you can DM within that....
6 Posted by mmd on 12 Dec, 2025 10:24 PM
https://infinitekind-public.slack.com/
says I need an @infinitekind.com email address
On Fri, Dec 12, 2025 at 4:16 PM, Stuart Beesley < [email blocked] > wrote:
7 Posted by mmd on 12 Dec, 2025 10:26 PM
Never mind found you
On Fri, Dec 12, 2025 at 4:16 PM, Stuart Beesley < [email blocked] > wrote:
8 Posted by Stuart Beesley ... on 12 Dec, 2025 10:28 PM
Moved to DM