From John Wiegley, Emacs ubercoder:
I've traded 60 Mb on my laptop for 60 Kb. How can you, too, lose three orders of magnitude of fat and waste on your hard drive?
By checking out the incredibly lean and mean "ledger" accounting tool. Written in C++, it parses it only, simplified general ledger file (intended for editing with Emacs), or it can even just parse GnuCash data files directly. This gives you the easiest way of starting out:
That will print out your GnuCash XML ledger data into much simpler, text-based "ledger" file.
Below is the code. For reading GnuCash, you'll need libxmltok1-dev installed (if you're a Debian user). It also uses GNU's multi-precision library (libgmp3-dev) and Perl regular expression library (libpcre3-dev).