A library to read and write QIF files
Switch branches/tags
Nothing to show
Pull request Compare This branch is 19 commits behind jemmyw:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
CHANGELOG
Gemfile
Gemfile.lock
LICENSE
Manifest
QIF_references
README.rdoc
Rakefile
qif.gemspec

README.rdoc

Library for reading Quicken Interchange Format (QIF) files

INSTALL:

  • sudo gem install qif

DOCUMENTATION:

EXAMPLE:

require 'qif'
qif = Qif::Reader.new(open('/path/to/file.qif'))
qif.each do |transaction|
  puts [transaction.name, transaction.description, transaction.amount].join(", ")
end

CSV conversion example

# Ruby 1.9.2
require 'csv'
require 'qif'

# file.csv is the source
#   [0] Date in dd/mm/yyyy,
#   [1] memo field,
#   [2] payee,
#   [3] debit amount,
#   [4] credit amount
#   Ignore other fields
basefile = 'file'
bank_input = CSV.read("#{file}.csv")

Qif::Writer.open("#{file}.qif", type = 'Bank', format = 'dd/mm/yyyy') do |qif|
  bank_input.each do |row|
    # Fix the values depending on what state your CSV data is in
    row.each { |value| value.to_s.gsub!(/^\s+|\s+$/,'') }
    qif << Qif::Transaction.new(
      :date         => row[0],
      :amount       => row[3].empty? ? row[4].to_f : -row[3].to_f,
      :memo         => row[1],
      :payee        => row[2]
    )
  end
end

LICENSE:

Copyright © 2011 Jeremy Wells

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.