Created
September 25, 2013 17:43
-
-
Save gavinheavyside/6703255 to your computer and use it in GitHub Desktop.
Reverse signs of transactions in a qif file, and open it (OS X) in the associated program. My bank generates .qif files for my credit card with credit & debit reversed compared with how my finance program wants them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'qif' | |
if ARGV.size != 1 | |
$stderr.puts "usage: fix-credit-card-qif-and-load.rb <CC qif file>" | |
end | |
input_filename = ARGV[0] | |
output_filename = input_filename.sub(/\.qif/, "-fixed.qif") | |
input = Qif::Reader.new(File.open(input_filename)) | |
Qif::Writer.open(output_filename) do |output| | |
input.each do |transaction| | |
transaction.amount = -transaction.amount | |
output << transaction | |
end | |
end | |
`open #{output_filename}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment