python parser of gnucash file

Dinesh Dutt ddutt at yahoo.com
Fri Jan 11 11:38:58 EST 2008


When I try running the program against my existing 2.2.2 version Gnucash file, 
I get the following error:
  Traceback (most recent call last):
  File "avg-monthly-chart.py", line 18, in <module>
    gc = gnucash.GNUCash(sys.argv[1])
  File "/usr/lib/python2.5/gnucash.py", line 351, in __init__
    self.accounts = self._get_all_accounts()
  File "/usr/lib/python2.5/gnucash.py", line 377, in _get_all_accounts
    return [Account(x) for x in self.xml.findall('//' + GNC_ACCOUNT)]
  File "/usr/lib/python2.5/gnucash.py", line 146, in __init__
    assert Account.Root == None
  AssertionError

When I issue the same command against a 2.0.5 version of the Gnucash file, I 
get the following error:
Traceback (most recent call last):
  File "avg-monthly-chart.py", line 72, in <module>
    ar.draw()
  File "/var/lib/python-support/python2.5/pychart/area.py", line 205, in draw
    self.y_grid_interval)
  File "/var/lib/python-support/python2.5/pychart/area.py", line 170, in 
__get_data_range
    this_min, this_max = plot.get_data_range(which)
  File "/var/lib/python-support/python2.5/pychart/bar_plot.py", line 165, in 
get_data_range
    return pychart_util.get_data_range(self._abs_data, self.hcol)
  File "/var/lib/python-support/python2.5/pychart/pychart_util.py", line 70, 
in get_data_range
    return (min(data), max(data))
ValueError: min() arg is an empty sequence

Dinesh

On Wednesday 09 January 2008 22:23:33 Justus Pendleton wrote:
> On the off chance anyone else actually cares....
>
> Once upon a time I tried to write some reports in gnucash and was
> discouraged by the lack of documentation (I don't mind the scheme aspect of
> it) and gave up. Fast forward several happy months of using gnucash and (it
> being year-end) I decide I want to figure out how to write some fancier
> reports about asset allocations and IRR and whatnot. Anyway, some googling
> around leads me to Xaprb's GnuCash to MySQL export script. Despite
> initially thinking that was what I wanted I soon realized that my brain is
> insufficiently SQLized to understand the included queries much less figure
> out how to write my own.
>
> A day later I had written a simple wrapper around the GnuCash XML file that
> parses it (using ElementTree, included in python 2.5) and presents it as a
> series of (hopefully) easy to navigate objects, along with some convenience
> methods. I've put up a small web page talking about it online[1] and the
> mercurial repository containing the work is also available[2]. I've
> included a couple of example reports that I've made in the past day,
> including a (IMHO) nifty one that creates an SVG graph of your average
> monthly expenditure over the past year in each account versus the actual
> expenditure over the past month[3].
>
> [1]: http://www.ryoohki.net/gnucash
> [2]: http://www.ryoohki.net/hg/gnucash
> [3]:
> http://www.ryoohki.net/hg/gnucash/file/tip/queries/avg-monthly-chart.py
>
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.



-- 
We make our world significant by the courage of our questions and by 
the depth of our answers.                               - Carl Sagan


More information about the gnucash-user mailing list