qiflib 0.0.4alpha → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,149 @@
1
+ == Qiflib
2
+
3
+ A ruby library for reading and parsing qif files.
4
+
5
+ Transaction parsing is supported, including address fields, and
6
+ up to three "splits" per transaction. See the DDL, below, for the
7
+ list of fields for each transaction.
8
+
9
+ Category-name parsing is also supported.
10
+
11
+ Also includes DDL generation for importing the parsed categories and
12
+ transactions into a sqlite3 database.
13
+
14
+ == Install
15
+
16
+ gem install qiflib
17
+
18
+ == Synopsis
19
+
20
+ # Parse the transactions from one or more files to csv.
21
+ # Due to a discrepancy between the way iBank and Quicken export
22
+ # qif files, you need to specify either Qiflib::SOURCE_IBANK or
23
+ # Qiflib::SOURCE_QUICKEN as the :source.
24
+
25
+ input_list = []
26
+ input_list << {
27
+ :owner => 'Chris',
28
+ :filename => 'data/ibank_cj.qif',
29
+ :source => Qiflib::SOURCE_IBANK }
30
+ input_list << {
31
+ :owner => 'Teri',
32
+ :filename => 'data/ibank_tj.qif',
33
+ :source => Qiflib::SOURCE_QUICKEN }
34
+
35
+ csv_lines = Qiflib::Util.transactions_to_csv(input_list)
36
+
37
+ ... write csv_lines to a file
38
+
39
+
40
+ # Parse the transactions from one or more files to ^-delimited text.
41
+ # The text lines are suitable for loading to sqlite3.
42
+
43
+ input_list = []
44
+ input_list << {
45
+ :owner => 'Chris',
46
+ :filename => 'data/ibank_cj.qif',
47
+ :source => Qiflib::SOURCE_IBANK }
48
+
49
+ delim_lines = Qiflib::Util.transactions_to_delim(input_list)
50
+
51
+ ... write delim_lines to a file
52
+
53
+
54
+ # Parse the categories from one or more files to csv.
55
+
56
+ input_list = [ 'data/ibank_cj.qif' ]
57
+ csv_lines = Qiflib::Util.catetory_names_to_csv(input_list)
58
+
59
+ ... write csv_lines to a file
60
+
61
+
62
+ # Parse the categories from one or more files to ^-delimited text.
63
+ # The text lines are suitable for loading to sqlite3.
64
+
65
+ input_list = [ 'data/ibank_cj.qif' ]
66
+ delim_lines = Qiflib::Util.catetory_names_to_delim(input_list)
67
+
68
+ ... write delim_lines to a file
69
+
70
+
71
+ # Generate the DDL for a sqlite3 database with categories and transactions tables.
72
+
73
+ ddl_lines = Qiflib::Util.generate_sqlite_ddl
74
+
75
+ ... write ddl_lines to a file; use it in the following bash-shell script
76
+
77
+
78
+ # Generate a bash-shell script to load the categories and transactions
79
+ # delimited files into a sqlite3 database, using the above DDL.
80
+
81
+ sh_lines = Qiflib::Util.generate_sqlite_load_script
82
+
83
+ ... write sh_lines to a file; chmod 744; run it.
84
+
85
+
86
+ == Generated DDL
87
+
88
+ # DDL file for sqlite3
89
+
90
+ drop table if exists transactions;
91
+ drop table if exists categories;
92
+
93
+ create table transactions(
94
+ id integer,
95
+ acct_owner varchar(80),
96
+ acct_name varchar(80),
97
+ acct_type varchar(80),
98
+ date varchar(80),
99
+ amount real,
100
+ number varchar(80),
101
+ ibank_n varchar(80),
102
+ cleared varchar(80),
103
+ payee varchar(80),
104
+ category varchar(80),
105
+ memo varchar(80),
106
+ split1_amount real,
107
+ split1_category varchar(80),
108
+ split1_memo real,
109
+ split2_amount varchar(80),
110
+ split2_category varchar(80),
111
+ split2_memo varchar(80),
112
+ split3_amount real,
113
+ split3_category varchar(80),
114
+ split3_memo varchar(80),
115
+ address1 varchar(80),
116
+ address2 varchar(80),
117
+ address3 varchar(80),
118
+ address4 varchar(80),
119
+ address5 varchar(80),
120
+ address6 varchar(80),
121
+ eol_ind char(1)
122
+ );
123
+
124
+ create table categories(
125
+ id integer,
126
+ name varchar(80)
127
+ );
128
+
129
+ .separator '^'
130
+
131
+ .import qiflib_transactions.txt transactions
132
+ .import qiflib_categories.txt categories
133
+
134
+
135
+ == Generated shell script
136
+
137
+ # bash-shell script
138
+
139
+ #!/bin/bash
140
+
141
+ sqlite3 qiflib.db < qiflib.ddl
142
+
143
+
144
+ == Copyright and License
145
+
146
+ Copyright 2012, Chris Joakim <cjoakim@bellsouth.net>.
147
+
148
+ GNU General Public License (GPLv3) license.
149
+ See http://www.gnu.org/copyleft/gpl.html
@@ -0,0 +1,377 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: Qiflib::Category</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../lib/qiflib_category_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/qiflib_category.rb">lib/qiflib_category.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Object</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-c-csv_header">::csv_header</a></li>
73
+
74
+ <li><a href="#method-c-new">::new</a></li>
75
+
76
+ <li><a href="#method-i-as_array">#as_array</a></li>
77
+
78
+ <li><a href="#method-i-to_csv">#to_csv</a></li>
79
+
80
+ </ul>
81
+ </div>
82
+
83
+
84
+ <!-- Included Modules -->
85
+
86
+ </div>
87
+
88
+ <div id="project-metadata">
89
+
90
+
91
+ <div id="fileindex-section" class="section project-section">
92
+ <h3 class="section-header">Files</h3>
93
+ <ul>
94
+
95
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
96
+
97
+ </ul>
98
+ </div>
99
+
100
+
101
+ <div id="classindex-section" class="section project-section">
102
+ <h3 class="section-header">Class Index
103
+ <span class="search-toggle"><img src="../images/find.png"
104
+ height="16" width="16" alt="[+]"
105
+ title="show/hide quicksearch" /></span></h3>
106
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
107
+ <fieldset>
108
+ <legend>Quicksearch</legend>
109
+ <input type="text" name="quicksearch" value=""
110
+ class="quicksearch-field" />
111
+ </fieldset>
112
+ </form>
113
+
114
+ <ul class="link-list">
115
+
116
+ <li><a href="../Qiflib.html">Qiflib</a></li>
117
+
118
+ <li><a href="../Qiflib/Category.html">Qiflib::Category</a></li>
119
+
120
+ <li><a href="../Qiflib/Date.html">Qiflib::Date</a></li>
121
+
122
+ <li><a href="../Qiflib/Money.html">Qiflib::Money</a></li>
123
+
124
+ <li><a href="../Qiflib/Transaction.html">Qiflib::Transaction</a></li>
125
+
126
+ <li><a href="../Qiflib/Util.html">Qiflib::Util</a></li>
127
+
128
+ </ul>
129
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
130
+ </div>
131
+
132
+
133
+ </div>
134
+ </div>
135
+
136
+ <div id="documentation">
137
+ <h1 class="class">Qiflib::Category</h1>
138
+
139
+ <div id="description">
140
+ <p>
141
+ Instances of this class represent a catgory parsed within the !Type:Cat
142
+ section of a qif file. The qiflib gem only captures the category name, and
143
+ not the other fields.
144
+ </p>
145
+
146
+ </div>
147
+
148
+ <!-- Constants -->
149
+
150
+
151
+ <!-- Attributes -->
152
+
153
+ <div id="attribute-method-details" class="method-section section">
154
+ <h3 class="section-header">Attributes</h3>
155
+
156
+
157
+ <div id="id-attribute-method" class="method-detail">
158
+ <a name="id"></a>
159
+
160
+ <a name="id="></a>
161
+
162
+ <div class="method-heading attribute-method-heading">
163
+ <span class="method-name">id</span><span
164
+ class="attribute-access-type">[RW]</span>
165
+ </div>
166
+
167
+ <div class="method-description">
168
+
169
+
170
+
171
+ </div>
172
+ </div>
173
+
174
+ <div id="name-attribute-method" class="method-detail">
175
+ <a name="name"></a>
176
+
177
+ <a name="name="></a>
178
+
179
+ <div class="method-heading attribute-method-heading">
180
+ <span class="method-name">name</span><span
181
+ class="attribute-access-type">[RW]</span>
182
+ </div>
183
+
184
+ <div class="method-description">
185
+
186
+
187
+
188
+ </div>
189
+ </div>
190
+
191
+ </div>
192
+
193
+
194
+ <!-- Methods -->
195
+
196
+ <div id="public-class-method-details" class="method-section section">
197
+ <h3 class="section-header">Public Class Methods</h3>
198
+
199
+
200
+ <div id="csv-header-method" class="method-detail ">
201
+ <a name="method-c-csv_header"></a>
202
+
203
+ <div class="method-heading">
204
+
205
+ <span class="method-name">csv_header</span><span
206
+ class="method-args">()</span>
207
+ <span class="method-click-advice">click to toggle source</span>
208
+
209
+ </div>
210
+
211
+ <div class="method-description">
212
+
213
+ <p>
214
+ Return the CSV header row.
215
+ </p>
216
+
217
+
218
+
219
+ <div class="method-source-code"
220
+ id="csv-header-source">
221
+ <pre>
222
+ <span class="ruby-comment cmt"># File lib/qiflib_category.rb, line 15</span>
223
+ 15: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">csv_header</span>
224
+ 16: <span class="ruby-constant">CSV</span>.<span class="ruby-identifier">generate</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">csv</span> <span class="ruby-operator">|</span>
225
+ 17: <span class="ruby-identifier">csv</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Qiflib</span><span class="ruby-operator">::</span><span class="ruby-identifier">csv_category_field_names</span>
226
+ 18: <span class="ruby-keyword kw">end</span>
227
+ 19: <span class="ruby-keyword kw">end</span></pre>
228
+ </div>
229
+
230
+ </div>
231
+
232
+
233
+
234
+
235
+ </div>
236
+
237
+
238
+ <div id="new-method" class="method-detail ">
239
+ <a name="method-c-new"></a>
240
+
241
+ <div class="method-heading">
242
+
243
+ <span class="method-name">new</span><span
244
+ class="method-args">(n=0)</span>
245
+ <span class="method-click-advice">click to toggle source</span>
246
+
247
+ </div>
248
+
249
+ <div class="method-description">
250
+
251
+ <p>
252
+ Constructor. The given n arg is an integer id value; defaults to 0.
253
+ </p>
254
+
255
+
256
+
257
+ <div class="method-source-code"
258
+ id="new-source">
259
+ <pre>
260
+ <span class="ruby-comment cmt"># File lib/qiflib_category.rb, line 23</span>
261
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">n</span>=<span class="ruby-value">0</span>)
262
+ 24: <span class="ruby-ivar">@id</span>, <span class="ruby-ivar">@name</span> = <span class="ruby-value">0</span>, <span class="ruby-node">&quot;#{n}&quot;</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>
263
+ 25: <span class="ruby-keyword kw">end</span></pre>
264
+ </div>
265
+
266
+ </div>
267
+
268
+
269
+
270
+
271
+ </div>
272
+
273
+
274
+ </div>
275
+
276
+ <div id="public-instance-method-details" class="method-section section">
277
+ <h3 class="section-header">Public Instance Methods</h3>
278
+
279
+
280
+ <div id="as-array-method" class="method-detail ">
281
+ <a name="method-i-as_array"></a>
282
+
283
+ <div class="method-heading">
284
+
285
+ <span class="method-name">as_array</span><span
286
+ class="method-args">(idx=0)</span>
287
+ <span class="method-click-advice">click to toggle source</span>
288
+
289
+ </div>
290
+
291
+ <div class="method-description">
292
+
293
+ <p>
294
+ Return this instance an 2-element array; id and name.
295
+ </p>
296
+
297
+
298
+
299
+ <div class="method-source-code"
300
+ id="as-array-source">
301
+ <pre>
302
+ <span class="ruby-comment cmt"># File lib/qiflib_category.rb, line 37</span>
303
+ 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">as_array</span>(<span class="ruby-identifier">idx</span>=<span class="ruby-value">0</span>)
304
+ 38: <span class="ruby-identifier">array</span> = []
305
+ 39: <span class="ruby-identifier">array</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
306
+ 40: <span class="ruby-identifier">array</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>
307
+ 41: <span class="ruby-identifier">array</span>
308
+ 42: <span class="ruby-keyword kw">end</span></pre>
309
+ </div>
310
+
311
+ </div>
312
+
313
+
314
+
315
+
316
+ </div>
317
+
318
+
319
+ <div id="to-csv-method" class="method-detail ">
320
+ <a name="method-i-to_csv"></a>
321
+
322
+ <div class="method-heading">
323
+
324
+ <span class="method-name">to_csv</span><span
325
+ class="method-args">(idx=0)</span>
326
+ <span class="method-click-advice">click to toggle source</span>
327
+
328
+ </div>
329
+
330
+ <div class="method-description">
331
+
332
+ <p>
333
+ Return this instance a CSV row.
334
+ </p>
335
+
336
+
337
+
338
+ <div class="method-source-code"
339
+ id="to-csv-source">
340
+ <pre>
341
+ <span class="ruby-comment cmt"># File lib/qiflib_category.rb, line 29</span>
342
+ 29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_csv</span>(<span class="ruby-identifier">idx</span>=<span class="ruby-value">0</span>)
343
+ 30: <span class="ruby-constant">CSV</span>.<span class="ruby-identifier">generate</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">csv</span> <span class="ruby-operator">|</span>
344
+ 31: <span class="ruby-identifier">csv</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">as_array</span>(<span class="ruby-identifier">idx</span>)
345
+ 32: <span class="ruby-keyword kw">end</span>
346
+ 33: <span class="ruby-keyword kw">end</span></pre>
347
+ </div>
348
+
349
+ </div>
350
+
351
+
352
+
353
+
354
+ </div>
355
+
356
+
357
+ </div>
358
+
359
+
360
+ </div>
361
+
362
+
363
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
364
+
365
+ <p>Disabled; run with --debug to generate this.</p>
366
+
367
+ </div>
368
+
369
+ <div id="validator-badges">
370
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
371
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
372
+ Rdoc Generator</a> 1.1.6</small>.</p>
373
+ </div>
374
+
375
+ </body>
376
+ </html>
377
+