Basic python script to convert CSVs to Ledger format
Python Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


csvToLedger – Convert CSVs to Ledger

This tool allows you to convert CSVs into a format appropriate for Ledger. It’s particularly useful when you need to specify multipart transactions.


-o “<File Path>”, —open=“<File Path>” CSV file to open
-s “<File Path>”, —save=“<File Path>” Save output to a file
-c “$”, —currency=“$” Currency character in data
-d “date”, —date=“date” Name of field containing transaction date
-n “note”, —note=“note” Name of field containing transaction note
-a “Assets:Checking, Equity:Revenue”, —accounts=“Assets:Checking, Equity:Revenue” Comma separated list of accounts
-f “payment, tax”, —fields=“payment, tax” Comma separated list of field names (in the CSV) to include with accounts. Fields prepended with a “-” will flip the sign of the field.

The following examples convert CSVs generated by TorchCL (Torch Project Management’s command line utility) to ledger format. The TorchCL commands that generated these files are:

torchCL --list="invoices" --save="invoices.csv"
torchCL --list="payments" --save="payments.csv"
torchCL --list="expenses" --save="expenses.csv"


./csvToLedger --open="../sample_csvs/invoices.csv" -a "Assets:Accounts Receivables, Liabilities:Taxes Payable, Equity:Revenue" -f "total,-tax" -d "date" -n "note" -s "../sample_csvs/save.txt"

Example File:

2008/08/23 * Bill for printing materials and hours
	Assets:Accounts Receivables		119.01
	Liabilities:Taxes Payable		(1.014000 * (-1))
2009/10/09 * Bill for services and servicing server
	Assets:Accounts Receivables		842.00
	Liabilities:Taxes Payable		(2.000000 * (-1))


./csvToLedger --open="../sample_csvs/payments.csv" -a "Assets:Checking, Assets:Accounts Receivables" -f "amount" -d "timestamp" -n "projectname" -s "../sample_csvs/save.txt"

Example File:

2011/03/03 * Newsletter Graphics
	Assets:Checking		105.000000
	Assets:Accounts Receivables
2011/03/03 * Newsletter Graphics
	Assets:Checking		26.000000
	Assets:Accounts Receivables


./csvToLedger --open="../sample_csvs/expenses.csv" -a "Equity:Expenses, Assets:Checking" -f "cost" -d "timestamp" -n "note" -s "../sample_csvs/save.txt"

Example File:

2011/02/01 * Equipment
	Equity:Expenses		150.000000
2009/09/27 * Flash Player License
	Equity:Expenses		100.000000
2009/09/27 * SVN Service
	Equity:Expenses		14.990000

The Super Easy Way to Install (Macports)

You can install this application using MacPorts! Type the following:

sudo port -v selfupdate
sudo port install csvToLedger

This method takes care of all dependancies and can manage updates for you. For information on installing MacPorts, please visit their site.


Installing csvToLedger is pretty easy. Because Macs and Linux already include Python, all you need to do is download the csvToLedger source, decompress it, and move it wherever you want. Of course, if you use csvToLedger a lot you might want to add your installation location to your PATH variable.

On Windows, you need to download Python 2.x and install it before installing csvToLedger. Or install the version of csvToLedger containing Python.


Windows (Zip file, Contains Python):
Windows (Zip file):
Max/Linux/Etc (tar.gz file):