parse xml file to get current balance in OpenOffice spreadsheet?
Josh Sled
jsled at asynchronous.org
Mon Feb 7 13:03:00 EST 2005
On Sat, 2005-02-05 at 17:31, Dan Drake wrote:
> If I could parse GnuCash's xml data file, this would be fairly easy.
>
> Is there a good way to do this? Ideally, I could write a little Python
> script that would spit out my net assets.
If you go with the "parsing the data file" route, you'll need to account
for GUID references [basically: object-references in the necessarily
graph-like data file], gnc-numeric data types, currencies, time and a
whole host of other stuff. There's no single "current balance" field in
the data file; you'll need to replay all the transactions up to the
current point.
The C-level [and scheme-level, for that matter] APIs to do it are pretty
straightforward, if you're willing to wade those waters. There's no
python bindings for the gnucash C libraries. There's no simple
programatic network API [RPC, XML/RPC, SOAP, HTTP or otherwise].
More simply, you may want to periodically generate -- manually -- the
appropriate report and save it as HTML, then extract the value from
that. That will deal with most of the application semantics, and give
you the single data-point you're after.
[To make that better: extend gnucash's command-line to support something
like "--generate <this-report> on <this-datafile> and export to
<this-html-file>.]
...jsled
--
http://asynchronous.org/ - `a=jsled; b=asynchronous.org; echo ${a}@${b}`
More information about the gnucash-user
mailing list