reckon 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.rdoc +31 -3
- data/VERSION +1 -1
- data/lib/reckon/app.rb +11 -5
- data/reckon.gemspec +3 -4
- data/spec/reckon/app_spec.rb +15 -1
- metadata +7 -5
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,34 @@
|
|
1
|
-
=
|
1
|
+
= Reckon
|
2
2
|
|
3
|
-
Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.
|
3
|
+
Reckon automagically converts CSV files for use with the command-line accounting tool Ledger[https://github.com/jwiegley/ledger/wiki]. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Assuming you have Ruby and Rubygems[http://rubygems.org/pages/download] installed on your system, simply run
|
8
|
+
|
9
|
+
(sudo) gem install reckon
|
10
|
+
|
11
|
+
== Example Usage
|
12
|
+
|
13
|
+
First, login to your bank and export your transaction data as a CSV file.
|
14
|
+
|
15
|
+
To see how the CSV parses:
|
16
|
+
|
17
|
+
reckon -f bank.csv -p
|
18
|
+
|
19
|
+
To convert to ledger format and label everything, do:
|
20
|
+
|
21
|
+
reckon -f bank.csv -o output.dat
|
22
|
+
|
23
|
+
To have reckon learn from an existing ledger file, provide it with -l:
|
24
|
+
|
25
|
+
reckon -f bank.csv -l 2010.dat -o output.dat
|
26
|
+
|
27
|
+
Learn more with
|
28
|
+
|
29
|
+
reckon -h
|
30
|
+
|
31
|
+
If you find CSV files that it can't parse, send me examples and I'll try to fix it.
|
4
32
|
|
5
33
|
== Note on Patches/Pull Requests
|
6
34
|
|
@@ -14,4 +42,4 @@ Reckon automagically converts CSV files for use with the command-line accounting
|
|
14
42
|
|
15
43
|
== Copyright
|
16
44
|
|
17
|
-
Copyright (c) 2010 Andrew Cantino. See LICENSE for details.
|
45
|
+
Copyright (c) 2010 Andrew Cantino, Iteration Labs, LLC. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/reckon/app.rb
CHANGED
@@ -171,7 +171,12 @@ module Reckon
|
|
171
171
|
def date_for(index)
|
172
172
|
value = columns[date_column_index][index]
|
173
173
|
value = [$1, $2, $3].join("/") if value =~ /^(\d{4})(\d{2})(\d{2})\d+\[\d+\:GMT\]$/ # chase format
|
174
|
-
|
174
|
+
begin
|
175
|
+
Time.parse(value)
|
176
|
+
rescue
|
177
|
+
puts "I'm having trouble parsing #{value}, which I thought was a date. Please report this so that we"
|
178
|
+
puts "can make this parser better!"
|
179
|
+
end
|
175
180
|
end
|
176
181
|
|
177
182
|
def pretty_date_for(index)
|
@@ -205,9 +210,10 @@ module Reckon
|
|
205
210
|
money_score -= 20 if entry !~ /^[\$\+\.\-,\d\(\)]+$/
|
206
211
|
possible_neg_money_count += 1 if entry =~ /^\$?[\-\(]\$?\d+/
|
207
212
|
possible_pos_money_count += 1 if entry =~ /^\+?\$?\+?\d+/
|
208
|
-
date_score += 10 if entry =~
|
209
|
-
date_score += entry
|
210
|
-
date_score
|
213
|
+
date_score += 10 if entry =~ /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i
|
214
|
+
date_score += 5 if entry =~ /^[\-\/\.\d:\[\]]+$/
|
215
|
+
date_score += entry.gsub(/[^\-\/\.\d:\[\]]/, '').length if entry.gsub(/[^\-\/\.\d:\[\]]/, '').length > 3
|
216
|
+
date_score -= entry.gsub(/[\-\/\.\d:\[\]]/, '').length
|
211
217
|
date_score += 30 if entry =~ /^\d+[:\/\.]\d+[:\/\.]\d+([ :]\d+[:\/\.]\d+)?$/
|
212
218
|
date_score += 10 if entry =~ /^\d+\[\d+:GMT\]$/i
|
213
219
|
end
|
@@ -286,7 +292,7 @@ module Reckon
|
|
286
292
|
unless row.all? { |i| i.nil? || i.length == 0 }
|
287
293
|
row.each_with_index do |entry, index|
|
288
294
|
memo[index] ||= []
|
289
|
-
memo[index] << entry.strip
|
295
|
+
memo[index] << (entry || '').strip
|
290
296
|
end
|
291
297
|
last_row_length = row.length
|
292
298
|
end
|
data/reckon.gemspec
CHANGED
@@ -5,15 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{reckon}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew Cantino"]
|
12
|
-
s.date = %q{2010-11-
|
13
|
-
s.default_executable = %q{reckon}
|
12
|
+
s.date = %q{2010-11-10}
|
14
13
|
s.description = %q{Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.}
|
15
14
|
s.email = %q{andrew@iterationlabs.com}
|
16
|
-
s.executables = ["reckon"]
|
15
|
+
s.executables = ["reckon", "reckon_local"]
|
17
16
|
s.extra_rdoc_files = [
|
18
17
|
"LICENSE",
|
19
18
|
"README.rdoc"
|
data/spec/reckon/app_spec.rb
CHANGED
@@ -20,22 +20,29 @@ describe Reckon::App do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "detect_columns" do
|
23
|
+
before do
|
24
|
+
@harder_date_example_csv = Reckon::App.new(:string => HARDER_DATE_EXAMPLE)
|
25
|
+
end
|
26
|
+
|
23
27
|
it "should detect the money column" do
|
24
28
|
@chase.money_column_indices.should == [3]
|
25
29
|
@some_other_bank.money_column_indices.should == [3]
|
26
30
|
@two_money_columns.money_column_indices.should == [3, 4]
|
31
|
+
@harder_date_example_csv.money_column_indices.should == [1]
|
27
32
|
end
|
28
33
|
|
29
34
|
it "should detect the date column" do
|
30
35
|
@chase.date_column_index.should == 1
|
31
36
|
@some_other_bank.date_column_index.should == 1
|
32
37
|
@two_money_columns.date_column_index.should == 0
|
38
|
+
@harder_date_example_csv.date_column_index.should == 0
|
33
39
|
end
|
34
40
|
|
35
41
|
it "should consider all other columns to be description columns" do
|
36
42
|
@chase.description_column_indices.should == [0, 2]
|
37
43
|
@some_other_bank.description_column_indices.should == [0, 2]
|
38
44
|
@two_money_columns.description_column_indices.should == [1, 2, 5]
|
45
|
+
@harder_date_example_csv.description_column_indices.should == [2, 3, 4, 5, 6, 7]
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
@@ -134,5 +141,12 @@ describe Reckon::App do
|
|
134
141
|
3/26/2008,Check - 0000000251,251,-$88.55,"","$1,298.57"
|
135
142
|
3/26/2008,Check - 0000000251,251,"","+$88.55","$1,298.57"
|
136
143
|
CSV
|
137
|
-
|
144
|
+
|
145
|
+
HARDER_DATE_EXAMPLE = (<<-CSV).strip
|
146
|
+
10-Nov-9,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER MORTGAGE,0.00,
|
147
|
+
09-Nov-10,123.12,,,SALARY SALARY,NGHSKS46383BGDJKD FOO BAR,432.12,
|
148
|
+
04-Nov-11,-1234.00,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MECU,0.00,
|
149
|
+
04-Nov-9,1234.00,,,TRANSFER CREDIT INTERNET TRANSFER,INTERNET TRANSFER,1234.00,
|
150
|
+
28-Oct-10,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MORTGAGE,0.00,
|
151
|
+
CSV
|
138
152
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reckon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Cantino
|
@@ -15,8 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
19
|
-
default_executable:
|
18
|
+
date: 2010-11-10 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rspec
|
@@ -86,6 +86,7 @@ description: Reckon automagically converts CSV files for use with the command-li
|
|
86
86
|
email: andrew@iterationlabs.com
|
87
87
|
executables:
|
88
88
|
- reckon
|
89
|
+
- reckon_local
|
89
90
|
extensions: []
|
90
91
|
|
91
92
|
extra_rdoc_files:
|
@@ -107,6 +108,7 @@ files:
|
|
107
108
|
- spec/reckon/ledger_parser_spec.rb
|
108
109
|
- spec/spec.opts
|
109
110
|
- spec/spec_helper.rb
|
111
|
+
- bin/reckon_local
|
110
112
|
has_rdoc: true
|
111
113
|
homepage: http://github.com/iterationlabs/reckon
|
112
114
|
licenses: []
|