Migration - Importing transactions via python binding

Łukasz Herok lukasz.infobox at gmail.com
Tue Jan 8 18:46:40 EST 2013


Hello,
I wanted to migrate to GnuCash from another program. I can export
transaction from the other program. I wanted to do so by generating
simple python script:

#!/usr/bin/env python
import os
import gnucash
from gnucash import Session, Account, Transaction, Split, GncNumeric

FILE_1 = "gnucash.gnucash"

session = Session("xml://%s" % FILE_1, is_new=False)
book = session.book
root = book.get_root_account()
comm_table = book.get_table()
pln = comm_table.lookup("CURRENCY", "PLN")
acc = root.lookup_by_name("Portfel")

trans1 = Transaction(book)
trans1.BeginEdit()

num1 = GncNumeric(4, 1)

split1 = Split(book)
split1.SetValue(num1)
split1.SetAccount(acc)
split1.SetParent(trans1)

trans1.SetCurrency(pln)
trans1.SetDate(8, 1, 2013)
trans1.SetDescription("Food")
trans1.CommitEdit()

session.save()
session.end()
session.destroy()


But I get an error:
CRIT <GLib> g_hash_table_foreach: assertion `version ==
hash_table->version' failed

1. Could you point me what's wrong?

2. Do you have a simpler idea to migrate? I can export whatever I want
(csv, ofx, sql). I need to import splited transactions.


More information about the gnucash-user mailing list