csv2ofx 0.29.0__tar.gz → 0.31.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csv2ofx-0.29.0/csv2ofx.egg-info → csv2ofx-0.31.0}/PKG-INFO +90 -37
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/README.md +70 -32
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/__init__.py +37 -7
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/main.py +74 -15
- csv2ofx-0.31.0/csv2ofx/mappings/amazon.py +61 -0
- csv2ofx-0.31.0/csv2ofx/mappings/ingesp.py +70 -0
- csv2ofx-0.31.0/csv2ofx/mappings/mint_extra.py +28 -0
- csv2ofx-0.31.0/csv2ofx/mappings/schwabchecking.py +67 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ubs-ch-fr.py +14 -9
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/ofx.py +280 -16
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/qif.py +10 -4
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/utils.py +12 -1
- {csv2ofx-0.29.0 → csv2ofx-0.31.0/csv2ofx.egg-info}/PKG-INFO +90 -37
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/SOURCES.txt +4 -6
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/requires.txt +1 -1
- csv2ofx-0.31.0/dev-requirements.txt +10 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/requirements.txt +1 -1
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/setup.cfg +4 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/tests/test.py +62 -3
- csv2ofx-0.29.0/csv2ofx/mappings/bnp.py +0 -17
- csv2ofx-0.29.0/csv2ofx/mappings/paychex.py +0 -24
- csv2ofx-0.29.0/dev-requirements.txt +0 -15
- csv2ofx-0.29.0/helpers/.DS_Store +0 -0
- csv2ofx-0.29.0/helpers/pippy +0 -61
- csv2ofx-0.29.0/tests/.DS_Store +0 -0
- csv2ofx-0.29.0/tests/pylintrc +0 -254
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/LICENSE +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/MANIFEST.in +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/bin/csv2ofx +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/__init__.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/abnamro.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/boursorama.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/capitalone.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/creditunion.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/custom.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/default.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/eqbank.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/exim.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/gls.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ingdirect.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mdb.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mint.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mint_headerless.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/mintapi.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/msmoneyreport.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/n26.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/outbank.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/pcmastercard.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/rabobank.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/split_account.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/starling.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/stripe.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/ubs.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/xero.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx/mappings/yodlee.py +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/dependency_links.txt +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/not-zip-safe +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/csv2ofx.egg-info/top_level.txt +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/OFX 2.1.1.pdf +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/OFXAudit.xls +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/OFX_Message_Support.doc +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_002.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_003.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_004.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/a_005.html +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/bootstrap.js +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/jquery.js +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/QIF Specification_files/sitecss.css +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/docs/qif-file-format.txt +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/helpers/check-stage +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/helpers/clean +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/helpers/srcdist +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/helpers/wheel +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/pyproject.toml +0 -0
- {csv2ofx-0.29.0 → csv2ofx-0.31.0}/setup.py +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: csv2ofx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.0
|
|
4
4
|
Summary: converts a csv file of transactions to an ofx or qif file
|
|
5
5
|
Home-page: https://github.com/reubano/csv2ofx
|
|
6
|
+
Download-URL: https://github.com/reubano/csv2ofx/archive/v0.31.0.tar.gz
|
|
6
7
|
Author: Reuben Cummings
|
|
7
8
|
Author-email: reubano@gmail.com
|
|
9
|
+
Maintainer: Jason R. Coombs
|
|
10
|
+
Maintainer-email: jaraco@jaraco.com
|
|
8
11
|
License: MIT
|
|
9
|
-
Download-URL: https://github.com/reubano/csv2ofx/archive/v0.29.0.tar.gz
|
|
10
12
|
Keywords: csv2ofx,converts,a,csv,file,of,transactions,to,an,ofx,or,qif,file
|
|
11
13
|
Platform: MacOS X
|
|
12
14
|
Platform: Windows
|
|
@@ -29,10 +31,25 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
29
31
|
Classifier: Operating System :: Microsoft :: Windows
|
|
30
32
|
Description-Content-Type: text/markdown
|
|
31
33
|
License-File: LICENSE
|
|
34
|
+
Requires-Dist: meza<0.48.0,>=0.47.0
|
|
35
|
+
Requires-Dist: python-dateutil<3.0.0,>=2.7.2
|
|
36
|
+
Requires-Dist: requests<3.0.0,>=2.18.4
|
|
37
|
+
Dynamic: author
|
|
38
|
+
Dynamic: author-email
|
|
39
|
+
Dynamic: classifier
|
|
40
|
+
Dynamic: description
|
|
41
|
+
Dynamic: description-content-type
|
|
42
|
+
Dynamic: download-url
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: keywords
|
|
45
|
+
Dynamic: license
|
|
46
|
+
Dynamic: platform
|
|
47
|
+
Dynamic: requires-dist
|
|
48
|
+
Dynamic: summary
|
|
32
49
|
|
|
33
50
|
# csv2ofx
|
|
34
51
|
|
|
35
|
-
[](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
|
|
36
53
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
37
54
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
38
55
|
|
|
@@ -112,29 +129,44 @@ usage: csv2ofx [options] <source> <dest>
|
|
|
112
129
|
description: csv2ofx converts a csv file to ofx and qif
|
|
113
130
|
|
|
114
131
|
positional arguments:
|
|
115
|
-
source the source csv file (
|
|
116
|
-
dest the output file (
|
|
132
|
+
source the source csv file (default: stdin)
|
|
133
|
+
dest the output file (default: stdout)
|
|
117
134
|
|
|
118
135
|
optional arguments:
|
|
119
136
|
-h, --help show this help message and exit
|
|
120
137
|
-a TYPE, --account TYPE
|
|
121
138
|
default account type 'CHECKING' for OFX and 'Bank' for QIF.
|
|
122
|
-
-e DATE, --end DATE end date
|
|
139
|
+
-e DATE, --end DATE end date (default: today)
|
|
140
|
+
-B BALANCE, --ending-balance BALANCE
|
|
141
|
+
ending balance (default: None)
|
|
123
142
|
-l LANGUAGE, --language LANGUAGE
|
|
124
|
-
the language
|
|
143
|
+
the language (default: ENG)
|
|
125
144
|
-s DATE, --start DATE
|
|
126
145
|
the start date
|
|
127
|
-
-
|
|
128
|
-
|
|
146
|
+
-y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
|
|
147
|
+
-m MAPPING_NAME, --mapping MAPPING_NAME
|
|
148
|
+
the account mapping (default: default)
|
|
149
|
+
-x FILE_PATH, --custom FILE_PATH
|
|
150
|
+
path to a custom mapping file
|
|
129
151
|
-c FIELD_NAME, --collapse FIELD_NAME
|
|
130
152
|
field used to combine transactions within a split for double entry statements
|
|
131
|
-
-S FIELD_NAME, --split FIELD_NAME
|
|
132
|
-
field used for the split account for single entry statements
|
|
133
153
|
-C ROWS, --chunksize ROWS
|
|
134
|
-
number of rows to process at a time
|
|
154
|
+
number of rows to process at a time (default: 2 ** 14)
|
|
155
|
+
-r ROWS, --first-row ROWS
|
|
156
|
+
the first row to process (zero based)
|
|
157
|
+
-R ROWS, --last-row ROWS
|
|
158
|
+
the last row to process (zero based, negative values count from the end)
|
|
159
|
+
-O COLS, --first-col COLS
|
|
160
|
+
the first column to process (zero based)
|
|
161
|
+
-L, --list-mappings list the available mappings
|
|
135
162
|
-V, --version show version and exit
|
|
136
163
|
-q, --qif enables 'QIF' output instead of 'OFX'
|
|
164
|
+
-M, --ms-money enables MS Money compatible 'OFX' output
|
|
137
165
|
-o, --overwrite overwrite destination file if it exists
|
|
166
|
+
-D DATE, --server-date DATE
|
|
167
|
+
OFX server date (default: source file mtime)
|
|
168
|
+
-E ENCODING, --encoding ENCODING
|
|
169
|
+
File encoding (default: utf-8)
|
|
138
170
|
-d, --debug display the options and arguments passed to the parser
|
|
139
171
|
-v, --verbose verbose output
|
|
140
172
|
```
|
|
@@ -163,14 +195,25 @@ optional arguments:
|
|
|
163
195
|
|
|
164
196
|
csv2ofx -m yoodlee file.csv
|
|
165
197
|
|
|
198
|
+
|
|
199
|
+
#### Special cases
|
|
200
|
+
|
|
201
|
+
Some banks, like *UBS Switzerland*, may provide CSV exports that are not
|
|
202
|
+
readily tractable by csv2ofx because of extra header or trailing lines,
|
|
203
|
+
redundant or unwanted columns. These input files can be preprocessed with the
|
|
204
|
+
shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
|
|
205
|
+
|
|
206
|
+
csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
|
|
207
|
+
|
|
208
|
+
|
|
166
209
|
## CUSTOMIZATION
|
|
167
210
|
|
|
168
211
|
### Code modification
|
|
169
212
|
|
|
170
|
-
If you would like to import csv files with field names different from the default, you can modify the mapping file or create your own. New mappings must be placed in the `csv2ofx/mappings` folder. The mapping object consists of a dictionary whose keys are OFX/QIF attributes and whose values are functions which should return the corresponding value from a record (csv row). The mapping function will take in a record, e.g.,
|
|
213
|
+
If you would like to import csv files with field names different from the default, you can modify the mapping file or create your own. New mappings must be placed in the `csv2ofx/mappings` folder (otherwise you must use the ). The mapping object consists of a dictionary whose keys are OFX/QIF attributes and whose values are functions which should return the corresponding value from a record (csv row). The mapping function will take in a record, e.g.,
|
|
171
214
|
|
|
172
215
|
```python
|
|
173
|
-
{'Account': 'savings 2', 'Date': '1/3/15', 'Amount':
|
|
216
|
+
{'Account': 'savings 2', 'Date': '1/3/15', 'Amount': 5000}
|
|
174
217
|
```
|
|
175
218
|
|
|
176
219
|
The most basic mapping function just returns a specific field or value, e.g.,
|
|
@@ -180,18 +223,22 @@ from operator import itemgetter
|
|
|
180
223
|
|
|
181
224
|
mapping = {
|
|
182
225
|
'bank': 'BetterBank',
|
|
183
|
-
'account': itemgetter('
|
|
184
|
-
'date': itemgetter('
|
|
185
|
-
'amount': itemgetter('
|
|
226
|
+
'account': itemgetter('Account'),
|
|
227
|
+
'date': itemgetter('Date'),
|
|
228
|
+
'amount': itemgetter('Amount')}
|
|
186
229
|
```
|
|
187
230
|
|
|
188
231
|
But more complex parsing is also possible, e.g.,
|
|
189
232
|
|
|
190
233
|
```python
|
|
191
234
|
mapping = {
|
|
192
|
-
'account': lambda r: r['
|
|
193
|
-
'date': lambda r: '%s/%s/%s' % (r['
|
|
194
|
-
'amount': lambda r: r['
|
|
235
|
+
'account': lambda r: r['Details'].split(':')[0],
|
|
236
|
+
'date': lambda r: '%s/%s/%s' % (r['Month'], r['Day'], r['Year']),
|
|
237
|
+
'amount': lambda r: r['Amount'] * 2,
|
|
238
|
+
'first_row': 1,
|
|
239
|
+
'last_row': 10,
|
|
240
|
+
'filter': lambda r: r['Amount'] > 10,
|
|
241
|
+
}
|
|
195
242
|
```
|
|
196
243
|
|
|
197
244
|
### Required field attributes
|
|
@@ -199,17 +246,8 @@ mapping = {
|
|
|
199
246
|
attribute | description | default field | example
|
|
200
247
|
----------|-------------|---------------------|--------
|
|
201
248
|
`account`|transaction account|Account|BetterBank Checking
|
|
202
|
-
`date`|transaction date|Date|
|
|
203
|
-
`amount`|transaction amount|Amount
|
|
204
|
-
|
|
205
|
-
### Optional value attributes
|
|
206
|
-
|
|
207
|
-
attribute | description | default value
|
|
208
|
-
----------|-------------|---------------
|
|
209
|
-
`has_header`|does the csv file have a header row|True
|
|
210
|
-
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
211
|
-
`currency`|the currency ISO code|USD
|
|
212
|
-
`delimiter`|the csv field delimiter|,
|
|
249
|
+
`date`|transaction date|Date|itemgetter('Transaction Date')
|
|
250
|
+
`amount`|transaction amount|Amount|itemgetter('Transaction Amount')
|
|
213
251
|
|
|
214
252
|
### Optional field attributes
|
|
215
253
|
|
|
@@ -221,11 +259,28 @@ attribute | description | default field | default value | example
|
|
|
221
259
|
`check_num`|the check or transaction number|Row|n/a|2
|
|
222
260
|
`id`|transaction id|`check_num`|Num|n/a|531
|
|
223
261
|
`bank`|the bank name|n/a|`account`|Bank
|
|
262
|
+
`account`|transaction account type|n/a|checking|savings
|
|
224
263
|
`account_id`|transaction account id|n/a|hash of `account`|bb_checking
|
|
225
|
-
`type`|transaction
|
|
264
|
+
`type`|transaction type (either debit or credit)|n/a|CREDIT if amount > 0 else DEBIT|debit
|
|
226
265
|
`balance`|account balance|n/a|n/a|$23.00
|
|
227
266
|
`class`|transaction class|n/a|n/a|travel
|
|
228
|
-
|
|
267
|
+
|
|
268
|
+
### Optional value attributes
|
|
269
|
+
|
|
270
|
+
attribute | description | default value | example
|
|
271
|
+
----------|-------------|---------------|--------
|
|
272
|
+
`has_header`|does the csv file have a header row|True
|
|
273
|
+
`custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
|
|
274
|
+
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
275
|
+
`currency`|the currency ISO code|USD|GBP
|
|
276
|
+
`delimiter`|the csv field delimiter|,|;
|
|
277
|
+
`date_fmt`|custom QIF date output format|%m/%d/%y|%m/%d/%Y
|
|
278
|
+
`dayfirst`|interpret the first value in ambiguous dates (e.g. 01/05/09) as the day (ignored if `parse_fmt` is present)|False|True
|
|
279
|
+
`parse_fmt`|transaction date parsing format||%m/%d/%Y
|
|
280
|
+
`first_row`|the first row to process (zero based)|0|2
|
|
281
|
+
`last_row`|the last row to process (zero based, negative values count from the end)|inf|-2
|
|
282
|
+
`first_col`|the first column to process (zero based)|0|2
|
|
283
|
+
`filter`|keep transactions for which function returns true||lambda tr: tr['amount'] > 10
|
|
229
284
|
|
|
230
285
|
## Scripts
|
|
231
286
|
|
|
@@ -260,7 +315,7 @@ cd csv2ofx
|
|
|
260
315
|
2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
|
|
261
316
|
|
|
262
317
|
```bash
|
|
263
|
-
mkvirtualenv
|
|
318
|
+
mkvirtualenv -i pkutils csv2ofx
|
|
264
319
|
activate csv2ofx
|
|
265
320
|
python setup.py develop
|
|
266
321
|
pip install -r dev-requirements.txt
|
|
@@ -287,5 +342,3 @@ How to contribute a mapping:
|
|
|
287
342
|
## License
|
|
288
343
|
|
|
289
344
|
csv2ofx is distributed under the [MIT License](http://opensource.org/licenses/MIT), the same as [meza](https://github.com/reubano/meza).
|
|
290
|
-
|
|
291
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# csv2ofx
|
|
2
2
|
|
|
3
|
-
[](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
|
|
4
4
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
5
5
|
[](https://pypi.python.org/pypi/csv2ofx)
|
|
6
6
|
|
|
@@ -80,29 +80,44 @@ usage: csv2ofx [options] <source> <dest>
|
|
|
80
80
|
description: csv2ofx converts a csv file to ofx and qif
|
|
81
81
|
|
|
82
82
|
positional arguments:
|
|
83
|
-
source the source csv file (
|
|
84
|
-
dest the output file (
|
|
83
|
+
source the source csv file (default: stdin)
|
|
84
|
+
dest the output file (default: stdout)
|
|
85
85
|
|
|
86
86
|
optional arguments:
|
|
87
87
|
-h, --help show this help message and exit
|
|
88
88
|
-a TYPE, --account TYPE
|
|
89
89
|
default account type 'CHECKING' for OFX and 'Bank' for QIF.
|
|
90
|
-
-e DATE, --end DATE end date
|
|
90
|
+
-e DATE, --end DATE end date (default: today)
|
|
91
|
+
-B BALANCE, --ending-balance BALANCE
|
|
92
|
+
ending balance (default: None)
|
|
91
93
|
-l LANGUAGE, --language LANGUAGE
|
|
92
|
-
the language
|
|
94
|
+
the language (default: ENG)
|
|
93
95
|
-s DATE, --start DATE
|
|
94
96
|
the start date
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
+
-y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
|
|
98
|
+
-m MAPPING_NAME, --mapping MAPPING_NAME
|
|
99
|
+
the account mapping (default: default)
|
|
100
|
+
-x FILE_PATH, --custom FILE_PATH
|
|
101
|
+
path to a custom mapping file
|
|
97
102
|
-c FIELD_NAME, --collapse FIELD_NAME
|
|
98
103
|
field used to combine transactions within a split for double entry statements
|
|
99
|
-
-S FIELD_NAME, --split FIELD_NAME
|
|
100
|
-
field used for the split account for single entry statements
|
|
101
104
|
-C ROWS, --chunksize ROWS
|
|
102
|
-
number of rows to process at a time
|
|
105
|
+
number of rows to process at a time (default: 2 ** 14)
|
|
106
|
+
-r ROWS, --first-row ROWS
|
|
107
|
+
the first row to process (zero based)
|
|
108
|
+
-R ROWS, --last-row ROWS
|
|
109
|
+
the last row to process (zero based, negative values count from the end)
|
|
110
|
+
-O COLS, --first-col COLS
|
|
111
|
+
the first column to process (zero based)
|
|
112
|
+
-L, --list-mappings list the available mappings
|
|
103
113
|
-V, --version show version and exit
|
|
104
114
|
-q, --qif enables 'QIF' output instead of 'OFX'
|
|
115
|
+
-M, --ms-money enables MS Money compatible 'OFX' output
|
|
105
116
|
-o, --overwrite overwrite destination file if it exists
|
|
117
|
+
-D DATE, --server-date DATE
|
|
118
|
+
OFX server date (default: source file mtime)
|
|
119
|
+
-E ENCODING, --encoding ENCODING
|
|
120
|
+
File encoding (default: utf-8)
|
|
106
121
|
-d, --debug display the options and arguments passed to the parser
|
|
107
122
|
-v, --verbose verbose output
|
|
108
123
|
```
|
|
@@ -131,14 +146,25 @@ optional arguments:
|
|
|
131
146
|
|
|
132
147
|
csv2ofx -m yoodlee file.csv
|
|
133
148
|
|
|
149
|
+
|
|
150
|
+
#### Special cases
|
|
151
|
+
|
|
152
|
+
Some banks, like *UBS Switzerland*, may provide CSV exports that are not
|
|
153
|
+
readily tractable by csv2ofx because of extra header or trailing lines,
|
|
154
|
+
redundant or unwanted columns. These input files can be preprocessed with the
|
|
155
|
+
shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
|
|
156
|
+
|
|
157
|
+
csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
|
|
158
|
+
|
|
159
|
+
|
|
134
160
|
## CUSTOMIZATION
|
|
135
161
|
|
|
136
162
|
### Code modification
|
|
137
163
|
|
|
138
|
-
If you would like to import csv files with field names different from the default, you can modify the mapping file or create your own. New mappings must be placed in the `csv2ofx/mappings` folder. The mapping object consists of a dictionary whose keys are OFX/QIF attributes and whose values are functions which should return the corresponding value from a record (csv row). The mapping function will take in a record, e.g.,
|
|
164
|
+
If you would like to import csv files with field names different from the default, you can modify the mapping file or create your own. New mappings must be placed in the `csv2ofx/mappings` folder (otherwise you must use the ). The mapping object consists of a dictionary whose keys are OFX/QIF attributes and whose values are functions which should return the corresponding value from a record (csv row). The mapping function will take in a record, e.g.,
|
|
139
165
|
|
|
140
166
|
```python
|
|
141
|
-
{'Account': 'savings 2', 'Date': '1/3/15', 'Amount':
|
|
167
|
+
{'Account': 'savings 2', 'Date': '1/3/15', 'Amount': 5000}
|
|
142
168
|
```
|
|
143
169
|
|
|
144
170
|
The most basic mapping function just returns a specific field or value, e.g.,
|
|
@@ -148,18 +174,22 @@ from operator import itemgetter
|
|
|
148
174
|
|
|
149
175
|
mapping = {
|
|
150
176
|
'bank': 'BetterBank',
|
|
151
|
-
'account': itemgetter('
|
|
152
|
-
'date': itemgetter('
|
|
153
|
-
'amount': itemgetter('
|
|
177
|
+
'account': itemgetter('Account'),
|
|
178
|
+
'date': itemgetter('Date'),
|
|
179
|
+
'amount': itemgetter('Amount')}
|
|
154
180
|
```
|
|
155
181
|
|
|
156
182
|
But more complex parsing is also possible, e.g.,
|
|
157
183
|
|
|
158
184
|
```python
|
|
159
185
|
mapping = {
|
|
160
|
-
'account': lambda r: r['
|
|
161
|
-
'date': lambda r: '%s/%s/%s' % (r['
|
|
162
|
-
'amount': lambda r: r['
|
|
186
|
+
'account': lambda r: r['Details'].split(':')[0],
|
|
187
|
+
'date': lambda r: '%s/%s/%s' % (r['Month'], r['Day'], r['Year']),
|
|
188
|
+
'amount': lambda r: r['Amount'] * 2,
|
|
189
|
+
'first_row': 1,
|
|
190
|
+
'last_row': 10,
|
|
191
|
+
'filter': lambda r: r['Amount'] > 10,
|
|
192
|
+
}
|
|
163
193
|
```
|
|
164
194
|
|
|
165
195
|
### Required field attributes
|
|
@@ -167,17 +197,8 @@ mapping = {
|
|
|
167
197
|
attribute | description | default field | example
|
|
168
198
|
----------|-------------|---------------------|--------
|
|
169
199
|
`account`|transaction account|Account|BetterBank Checking
|
|
170
|
-
`date`|transaction date|Date|
|
|
171
|
-
`amount`|transaction amount|Amount
|
|
172
|
-
|
|
173
|
-
### Optional value attributes
|
|
174
|
-
|
|
175
|
-
attribute | description | default value
|
|
176
|
-
----------|-------------|---------------
|
|
177
|
-
`has_header`|does the csv file have a header row|True
|
|
178
|
-
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
179
|
-
`currency`|the currency ISO code|USD
|
|
180
|
-
`delimiter`|the csv field delimiter|,
|
|
200
|
+
`date`|transaction date|Date|itemgetter('Transaction Date')
|
|
201
|
+
`amount`|transaction amount|Amount|itemgetter('Transaction Amount')
|
|
181
202
|
|
|
182
203
|
### Optional field attributes
|
|
183
204
|
|
|
@@ -189,11 +210,28 @@ attribute | description | default field | default value | example
|
|
|
189
210
|
`check_num`|the check or transaction number|Row|n/a|2
|
|
190
211
|
`id`|transaction id|`check_num`|Num|n/a|531
|
|
191
212
|
`bank`|the bank name|n/a|`account`|Bank
|
|
213
|
+
`account`|transaction account type|n/a|checking|savings
|
|
192
214
|
`account_id`|transaction account id|n/a|hash of `account`|bb_checking
|
|
193
|
-
`type`|transaction
|
|
215
|
+
`type`|transaction type (either debit or credit)|n/a|CREDIT if amount > 0 else DEBIT|debit
|
|
194
216
|
`balance`|account balance|n/a|n/a|$23.00
|
|
195
217
|
`class`|transaction class|n/a|n/a|travel
|
|
196
|
-
|
|
218
|
+
|
|
219
|
+
### Optional value attributes
|
|
220
|
+
|
|
221
|
+
attribute | description | default value | example
|
|
222
|
+
----------|-------------|---------------|--------
|
|
223
|
+
`has_header`|does the csv file have a header row|True
|
|
224
|
+
`custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
|
|
225
|
+
`is_split`|does the csv file contain split (double entry) transactions|False
|
|
226
|
+
`currency`|the currency ISO code|USD|GBP
|
|
227
|
+
`delimiter`|the csv field delimiter|,|;
|
|
228
|
+
`date_fmt`|custom QIF date output format|%m/%d/%y|%m/%d/%Y
|
|
229
|
+
`dayfirst`|interpret the first value in ambiguous dates (e.g. 01/05/09) as the day (ignored if `parse_fmt` is present)|False|True
|
|
230
|
+
`parse_fmt`|transaction date parsing format||%m/%d/%Y
|
|
231
|
+
`first_row`|the first row to process (zero based)|0|2
|
|
232
|
+
`last_row`|the last row to process (zero based, negative values count from the end)|inf|-2
|
|
233
|
+
`first_col`|the first column to process (zero based)|0|2
|
|
234
|
+
`filter`|keep transactions for which function returns true||lambda tr: tr['amount'] > 10
|
|
197
235
|
|
|
198
236
|
## Scripts
|
|
199
237
|
|
|
@@ -228,7 +266,7 @@ cd csv2ofx
|
|
|
228
266
|
2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
|
|
229
267
|
|
|
230
268
|
```bash
|
|
231
|
-
mkvirtualenv
|
|
269
|
+
mkvirtualenv -i pkutils csv2ofx
|
|
232
270
|
activate csv2ofx
|
|
233
271
|
python setup.py develop
|
|
234
272
|
pip install -r dev-requirements.txt
|
|
@@ -37,16 +37,21 @@ __package_name__ = "csv2ofx"
|
|
|
37
37
|
__author__ = "Reuben Cummings"
|
|
38
38
|
__description__ = "converts a csv file of transactions to an ofx or qif file"
|
|
39
39
|
__email__ = "reubano@gmail.com"
|
|
40
|
-
__version__ = "0.
|
|
40
|
+
__version__ = "0.31.0"
|
|
41
41
|
__license__ = "MIT"
|
|
42
42
|
__copyright__ = "Copyright 2015 Reuben Cummings"
|
|
43
43
|
|
|
44
|
-
DEF_DATE_FMT = "%m/%d/%Y"
|
|
45
44
|
|
|
46
45
|
# pylint: disable=invalid-name
|
|
47
46
|
md5 = lambda content: hashlib.md5(content.encode("utf-8")).hexdigest()
|
|
48
47
|
|
|
49
48
|
|
|
49
|
+
class BalanceError(Exception):
|
|
50
|
+
"""Raised if no ending balance when MS Money compatible output requested"""
|
|
51
|
+
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
50
55
|
class Content(object): # pylint: disable=too-many-instance-attributes
|
|
51
56
|
"""A transaction holding object"""
|
|
52
57
|
|
|
@@ -60,6 +65,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
60
65
|
start (date): Date from which to begin including transactions.
|
|
61
66
|
end (date): Date from which to exclude transactions.
|
|
62
67
|
date_fmt (str): Transaction date format (defaults to '%m/%d/%y').
|
|
68
|
+
dayfirst (bool): Interpret the first value in ambiguous dates (e.g. 01/05/09)
|
|
69
|
+
as the day (ignored if `parse_fmt` is present).
|
|
70
|
+
filter (func): Keep transactions for which function returns true
|
|
63
71
|
|
|
64
72
|
Examples:
|
|
65
73
|
>>> from csv2ofx.mappings.mint import mapping
|
|
@@ -71,7 +79,10 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
71
79
|
# pylint doesn't like dynamically set attributes...
|
|
72
80
|
self.amount = 0
|
|
73
81
|
self.account = "N/A"
|
|
74
|
-
self.
|
|
82
|
+
self.parse_fmt = kwargs.get("parse_fmt")
|
|
83
|
+
self.dayfirst = kwargs.get("dayfirst")
|
|
84
|
+
self.filter = kwargs.get("filter")
|
|
85
|
+
self.ms_money = kwargs.get("ms_money")
|
|
75
86
|
self.split_account = None
|
|
76
87
|
self.inv_split_account = None
|
|
77
88
|
self.id = None
|
|
@@ -81,6 +92,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
81
92
|
if not hasattr(self, "is_split"):
|
|
82
93
|
self.is_split = False
|
|
83
94
|
|
|
95
|
+
if not hasattr(self, "has_header"):
|
|
96
|
+
self.has_header = True
|
|
97
|
+
|
|
84
98
|
if not callable(self.account):
|
|
85
99
|
account = self.account
|
|
86
100
|
self.account = lambda _: account
|
|
@@ -88,6 +102,14 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
88
102
|
self.start = kwargs.get("start") or dt(1970, 1, 1)
|
|
89
103
|
self.end = kwargs.get("end") or dt.now()
|
|
90
104
|
|
|
105
|
+
def parse_date(self, trxn):
|
|
106
|
+
if self.parse_fmt:
|
|
107
|
+
parsed = dt.strptime(self.get("date", trxn), self.parse_fmt)
|
|
108
|
+
else:
|
|
109
|
+
parsed = parse(self.get("date", trxn), dayfirst=self.dayfirst)
|
|
110
|
+
|
|
111
|
+
return parsed
|
|
112
|
+
|
|
91
113
|
def get(self, name, trxn=None, default=None):
|
|
92
114
|
"""Gets an attribute which could be either a normal attribute,
|
|
93
115
|
a mapping function, or a mapping attribute
|
|
@@ -136,7 +158,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
136
158
|
|
|
137
159
|
def skip_transaction(self, trxn):
|
|
138
160
|
"""Determines whether a transaction should be skipped (isn't in the
|
|
139
|
-
specified date range)
|
|
161
|
+
specified date range, etc.)
|
|
140
162
|
|
|
141
163
|
Args:
|
|
142
164
|
trxn (dict): The transaction.
|
|
@@ -154,7 +176,8 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
154
176
|
>>> Content(mapping, start=dt(2013, 1, 1)).skip_transaction(trxn)
|
|
155
177
|
True
|
|
156
178
|
"""
|
|
157
|
-
|
|
179
|
+
keep = self.end >= self.parse_date(trxn) >= self.start
|
|
180
|
+
return not (self.filter(trxn) if keep and self.filter else keep)
|
|
158
181
|
|
|
159
182
|
def convert_amount(self, trxn):
|
|
160
183
|
"""Converts a string amount into a number
|
|
@@ -173,6 +196,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
173
196
|
>>> trxn = {'Date': '06/12/10', 'Amount': '$1,000'}
|
|
174
197
|
>>> Content(mapping, start=dt(2010, 1, 1)).convert_amount(trxn)
|
|
175
198
|
Decimal('1000.00')
|
|
199
|
+
>>> trxn = {'Date': '06/12/10', 'Amount': '1.000,00€'}
|
|
200
|
+
>>> Content(mapping, start=dt(2010, 1, 1)).convert_amount(trxn)
|
|
201
|
+
Decimal('1000.00')
|
|
176
202
|
"""
|
|
177
203
|
return utils.convert_amount(self.get("amount", trxn))
|
|
178
204
|
|
|
@@ -207,7 +233,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
207
233
|
... 'split_account': 'Checking', 'type': 'DEBIT',
|
|
208
234
|
... 'category': '', 'amount': Decimal('-1000.00'),
|
|
209
235
|
... 'memo': 'description notes', 'inv_split_account': None,
|
|
210
|
-
... 'x_action': ''}
|
|
236
|
+
... 'x_action': '', 'balance': None}
|
|
211
237
|
True
|
|
212
238
|
"""
|
|
213
239
|
account = self.get("account", trxn)
|
|
@@ -232,6 +258,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
232
258
|
symbol = self.get("symbol", trxn, "")
|
|
233
259
|
price = Decimal(self.get("price", trxn, 0))
|
|
234
260
|
invest = shares or (symbol and symbol != "N/A") or "invest" in category
|
|
261
|
+
balance = self.get("balance", trxn)
|
|
262
|
+
if balance is not None:
|
|
263
|
+
balance = utils.convert_amount(balance)
|
|
235
264
|
|
|
236
265
|
if invest:
|
|
237
266
|
amount = abs(amount)
|
|
@@ -246,7 +275,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
246
275
|
x_action = ""
|
|
247
276
|
|
|
248
277
|
return {
|
|
249
|
-
"date":
|
|
278
|
+
"date": self.parse_date(trxn),
|
|
250
279
|
"currency": self.get("currency", trxn, "USD"),
|
|
251
280
|
"shares": shares,
|
|
252
281
|
"symbol": symbol,
|
|
@@ -269,6 +298,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
|
|
|
269
298
|
"id": self.get("id", trxn, check_num) or md5(details),
|
|
270
299
|
"check_num": check_num,
|
|
271
300
|
"type": _type,
|
|
301
|
+
"balance": balance,
|
|
272
302
|
}
|
|
273
303
|
|
|
274
304
|
def gen_trxns(self, groups, collapse=False):
|