A sloppy guide to GnuCash's Python bindings
Hi! The other day I was building some script to parse some bank extracts and merge it into a GnuCash database through a Python script. GnuCash's offers some Python bindings to interact with it, but the documentation is a bit lacking.
The Python bindings can be understood looking into the sample scripts
[1]
[2]
[3]
and a bit of Python's help()
.
But if you want another entry point here is a bit of a sloppy quickstart to see how to open a GnuCash file, read it's transactions and add a new one.
(Note: If your file is stored in a SQL format you might be able to use piecash to access it. I can't talk about the how friendly that library is, but it's documentation is much more extensive).
(Also note: I'm not an expert user (or someone with accounting knowledge for that matter) and I won't go into how to use GnuCash generally as a software tool… maybe check it's wiki or it's Quick Start Guide For Business Users for that 🤷.)
But first…
What is GnuCash?
According to it's website…
GnuCash is personal and small-business financial-accounting software, freely licensed under the GNU GPL […]. Designed to be easy to use, yet powerful and flexible, GnuCash allows you to track bank accounts, stocks, income and expenses. As quick and intuitive to use as a checkbook register, it is based on professional accounting principles to ensure balanced books and accurate reports.