README
1 gnucash2ledger
gnucash2ledger is a Python script based on the Github Gist by nonducor (nonducor/gcash2ledger.py). This Python script will take an uncompressed Gnucash file saved in the default XML format and write a text file in a format compatible with John Wiegley’s ledger program (Github: ledger/ledger).
Note: gnucash2ledger will only work if the Gnucash data is saved in an uncompressed XML file. If you prefer to save your Gnucash in SQL database formats, checkout the piecash project.
1.1 Features
gnucash2ledger has the following features:
- Allows for export to a text file or prints results to standard output
- Exports commodity definitions, account definitions, and transactions with splits
- Supports multiple commodities/currencies
- Provides and option to insert a default header for Emacs
ledger-mode
(Github: ledger/ledger-mode) - Currency codes can be replaced by currency symbols using Python CurrencySymbols library
- Provides an option to display progress bars (useful for converting very long Gnucash files)
1.2 Usage
gnucash2ledger.py [-h] [-c] [-d DATE_FORMAT] [-e] [-f] [-na] [-nc] [-nt] [-o FILENAME] [-p] [--payee-metadata] [-s] [-v] input
1.2.1 Command Line Arguments
Output from gnucash2ledger -h
positional arguments: input a Gnucash XML file to be read optional arguments: -h, --help show this help message and exit -c, --cleared Marks all transactions as cleared and place a cleared (*) mark before the transaction heading. -d DATE_FORMAT, --date-format DATE_FORMAT A string representing the desired format of dates in the ledger file. Defaults to the ISO standard format: '%Y-%m-%d'. -e, --emacs-header Adds a default header for ledger-mode in Emacs. -f, --force-clobber Force clobbering of and output file i the file already exists. If this option is provided, the output file will overwrite the existing file with the same name. -na, --no-account-defs Prevents output of account definitions to the output file. -nc, --no-commodity-defs Prevent output of commodities to the output file. -nt, --no-transations Prevent output of transactions to the output file. NOTE: This will cause ledger to throw an error if executed on this file. -o FILENAME, --output FILENAME Name of file to store the output results. -p, --show-progress Show script status progress while reading and writing data. --payee-metadata Takes the information entered into the 'Description' field in Gnucash splits and adds them as a tagged '; Payee:' memo for the corresponding transaction split. -s, --use-symbols Replaces currency codes with currency symbols. -v, --version show program's version number and exit
1.3 Requirements
gnucash2ledger requires that the following Python packages are installed:
- currency-symbols
- tqdm