Python help - switch memo and description

Paul's Avatar

Paul

16 Nov, 2016 06:10 AM

I've imported a lot of data and my memos and descriptions are backwards. I've made changes since then and don't want to reimport.

Can anyone suggest a python snippet to switch memo and description for every transaction? I have some very basic experience with python, but none with python within Moneydance.

Thanks in advance.

Paul

  1. 1 Posted by Paul on 16 Nov, 2016 07:05 AM

    Paul's Avatar

    Edit:
    Here's what I have so far. It gets memo and description info fine, and ignores splits and transactions with no memo.

    But trying to actually edit the transaction yields nothing. The transactions stay as they were. What am I missing?

    #!/usr/bin/env python
    # Python script to be run in Moneydance to perform amazing feats of financial scripting

    from com.infinitekind.moneydance.model import *

    import sys
    import time

    # get the default environment variables, set by Moneydance
    print "The Moneydance app controller: %s"%(moneydance)
    print "The current data set: %s"%(moneydance_data)
    print "The UI: %s"%(moneydance_ui)

    if moneydance_data:
    txnSet = moneydance_data.getTransactionSet()

    counter = 0

    for txn in txnSet.iterableTxns():
    try:
    txn.getOtherTxn(1)
    continue # it's a split transaction. ignore and loop again
    except:
    pass # it's not a split transaction. let's keep going
    desc = txn.getDescription()
    memo = txn.getMemo()
    print desc
    print memo
    if memo != '':
    txn.setDescription(memo)
    txn.setMemo(desc)

  2. 2 Posted by virantha on 16 Nov, 2016 03:52 PM

    virantha's Avatar

    Have you tried calling .syncItem() on your txn after changing it?

  3. 3 Posted by Paul Wirth on 17 Nov, 2016 12:22 AM

    Paul Wirth's Avatar

    Thank you!

  4. System closed this discussion on 16 Feb, 2017 12:30 AM.

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