Faster way to search for existing FiTxnId?

mmd's Avatar

mmd

12 Dec, 2025 06:36 PM

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.

  1. 1 Posted by Stuart Beesley ... on 12 Dec, 2025 08:25 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    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. 2 Posted by Stuart Beesley ... on 12 Dec, 2025 08:26 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Or getTransactionsForAccount() is you want a TxnSet rather than a list.

  3. 3 Posted by mmd on 12 Dec, 2025 09:42 PM

    mmd's Avatar

    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. 4 Posted by mmd on 12 Dec, 2025 10:01 PM

    mmd's Avatar

    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. 5 Posted by Stuart Beesley ... on 12 Dec, 2025 10:16 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    There is a Slack forum for MD and you can DM within that....

  6. 6 Posted by mmd on 12 Dec, 2025 10:24 PM

    mmd's Avatar

    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. 7 Posted by mmd on 12 Dec, 2025 10:26 PM

    mmd's Avatar

    Never mind found you

    On Fri, Dec 12, 2025 at 4:16 PM, Stuart Beesley < [email blocked] > wrote:

  8. 8 Posted by Stuart Beesley ... on 12 Dec, 2025 10:28 PM

    Stuart Beesley (Mr Toolbox)'s Avatar

    Moved to DM

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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

Recent Discussions

14 Jan, 2026 04:26 AM
14 Jan, 2026 02:16 AM
14 Jan, 2026 01:38 AM
14 Jan, 2026 01:07 AM
14 Jan, 2026 12:43 AM