As Chop Sui said, GnuCash 2.4 has its own database format. If you still want to use XML files, you can use the following script to convert from XML to a database, and then write your reports (e.g. gnucashconvert filename.gnucash sqlite3: ////home/username/export.sqlite):
import os
import gnucash
def convert_gnucash(src_uri, target_uri):
"""Converts gnucash databases at the given uris from src to target"""
session = gnucash.Session(src_uri)
try:
new_session = gnucash.Session(target_uri, is_new=True)
try:
new_session.swap_data(session)
new_session.save()
finally:
new_session.end()
new_session.destroy()
finally:
session.end()
session.destroy()
if __name__ == "__main__":
import sys
if len(sys.argv) > 2:
src_uri, target_uri = sys.argv[1], sys.argv[2]
src_uri = ("xml://%s" % os.path.abspath(src_uri) if "://" not in src_uri else src_uri)
target_uri = ("xml://%s" % os.path.abspath(target_uri) if "://" not in target_uri else target_uri)
convert_gnucash(src_uri, target_uri)
else:
print >>sys.stderr, "Syntax %s src target" % (sys.argv[0])
source
share