Skip to content

hse-project/Qif

 
 

Repository files navigation

<img src=“https://travis-ci.org/jemmyw/Qif.png?branch=master” alt=“Build Status” />

Library for reading Quicken Interchange Format (QIF) files

INSTALL:

  • gem install qif

DOCUMENTATION:

EXAMPLE:

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

CSV conversion example

# Ruby 2.1.0
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 = 'filename'
bank_input = CSV.read("#{basefile}.csv")

Qif::Writer.open("#{basefile}.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 © 2014 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.

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%