Skip to content

Instantly share code, notes, and snippets.

@ashleyhindle
Created September 10, 2015 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashleyhindle/161b0e3affee8290f3cb to your computer and use it in GitHub Desktop.
Save ashleyhindle/161b0e3affee8290f3cb to your computer and use it in GitHub Desktop.
qif2csv qif to csv xls
#!/usr/bin/ruby
# Usage:
# gem install qif
# ./qif2csv.rb [input.qif] [output.sv]
require 'qif'
require 'csv'
if ARGV.empty? || ARGV.length < 2
puts "Usage: ./qif2csv.rb [input.qif] [output.csv]"
exit
end
qif = Qif::Reader.new(open(ARGV[0]))
csv = CSV.open(ARGV[1], "w")
csv << ["Date", "Info", "Amount"]
qif.each do |transaction|
csv << [transaction.date, transaction.payee.to_s, transaction.amount]
end
csv.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment