Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit bb85a6ddb6d0ca436f2980bf716fb378c639e157 @chrisroos committed Jan 28, 2011
Showing with 56 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +8 −0 Gemfile
  3. +22 −0 Gemfile.lock
  4. +25 −0 ofx-to-csv.rb
1 .gitignore
@@ -0,0 +1 @@
+tmp/*
8 Gemfile
@@ -0,0 +1,8 @@
+source :rubygems
+
+gem 'ofx-parser'
+gem 'fastercsv'
+
+# Manually require i18n because ActiveSupport, for whatever reason, doesn't require it
+gem 'i18n'
+gem 'activesupport'
22 Gemfile.lock
@@ -0,0 +1,22 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (3.0.3)
+ fastercsv (1.5.3)
+ hoe (2.8.0)
+ rake (>= 0.8.7)
+ hpricot (0.8.3)
+ i18n (0.5.0)
+ ofx-parser (1.0.2)
+ hoe (>= 1.5.1)
+ hpricot (>= 0.6)
+ rake (0.8.7)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activesupport
+ fastercsv
+ i18n
+ ofx-parser
25 ofx-to-csv.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'bundler/setup'
+
+require 'ofx-parser'
+require 'fastercsv'
+require 'active_support/inflector'
+
+ofx_file = ARGV.shift
+unless ofx_file and File.exists?(ofx_file)
+ puts "Usage: #{File.basename(__FILE__)} /path/to/statement.ofx"
+ exit 1
+end
+
+ofx = OfxParser::OfxParser.parse(open(ofx_file))
+
+ofx.bank_account.statement.transactions.each do |transaction|
+ date = transaction.date.strftime('%Y-%m-%d')
+ payee = ActiveSupport::Inflector.titleize(transaction.payee)
+ memo = ActiveSupport::Inflector.titleize(transaction.memo)
+ type = ActiveSupport::Inflector.titleize(transaction.type)
+
+ puts [date, transaction.fit_id, payee, memo, type, transaction.amount].to_csv
+end

0 comments on commit bb85a6d

Please sign in to comment.