csv2ofx 0.30.0__tar.gz → 0.32.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.
Files changed (79) hide show
  1. {csv2ofx-0.30.0/csv2ofx.egg-info → csv2ofx-0.32.0}/PKG-INFO +37 -34
  2. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/README.md +28 -13
  3. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/__init__.py +13 -2
  4. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/main.py +26 -8
  5. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/ofx.py +280 -16
  6. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/qif.py +2 -1
  7. {csv2ofx-0.30.0 → csv2ofx-0.32.0/csv2ofx.egg-info}/PKG-INFO +37 -34
  8. csv2ofx-0.32.0/csv2ofx.egg-info/SOURCES.txt +35 -0
  9. csv2ofx-0.32.0/csv2ofx.egg-info/entry_points.txt +2 -0
  10. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/requires.txt +1 -1
  11. csv2ofx-0.32.0/dev-requirements.txt +3 -0
  12. csv2ofx-0.32.0/pyproject.toml +39 -0
  13. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/requirements.txt +1 -1
  14. csv2ofx-0.32.0/setup.cfg +4 -0
  15. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/tests/test.py +66 -3
  16. csv2ofx-0.30.0/bin/csv2ofx +0 -16
  17. csv2ofx-0.30.0/csv2ofx/mappings/__init__.py +0 -6
  18. csv2ofx-0.30.0/csv2ofx/mappings/abnamro.py +0 -12
  19. csv2ofx-0.30.0/csv2ofx/mappings/bnp.py +0 -17
  20. csv2ofx-0.30.0/csv2ofx/mappings/boursorama.py +0 -18
  21. csv2ofx-0.30.0/csv2ofx/mappings/capitalone.py +0 -15
  22. csv2ofx-0.30.0/csv2ofx/mappings/creditunion.py +0 -14
  23. csv2ofx-0.30.0/csv2ofx/mappings/custom.py +0 -21
  24. csv2ofx-0.30.0/csv2ofx/mappings/default.py +0 -17
  25. csv2ofx-0.30.0/csv2ofx/mappings/eqbank.py +0 -14
  26. csv2ofx-0.30.0/csv2ofx/mappings/exim.py +0 -13
  27. csv2ofx-0.30.0/csv2ofx/mappings/gls.py +0 -25
  28. csv2ofx-0.30.0/csv2ofx/mappings/ingdirect.py +0 -20
  29. csv2ofx-0.30.0/csv2ofx/mappings/mdb.py +0 -22
  30. csv2ofx-0.30.0/csv2ofx/mappings/mint.py +0 -23
  31. csv2ofx-0.30.0/csv2ofx/mappings/mint_extra.py +0 -28
  32. csv2ofx-0.30.0/csv2ofx/mappings/mint_headerless.py +0 -22
  33. csv2ofx-0.30.0/csv2ofx/mappings/mintapi.py +0 -30
  34. csv2ofx-0.30.0/csv2ofx/mappings/msmoneyreport.py +0 -16
  35. csv2ofx-0.30.0/csv2ofx/mappings/n26.py +0 -34
  36. csv2ofx-0.30.0/csv2ofx/mappings/outbank.py +0 -23
  37. csv2ofx-0.30.0/csv2ofx/mappings/paychex.py +0 -24
  38. csv2ofx-0.30.0/csv2ofx/mappings/pcmastercard.py +0 -15
  39. csv2ofx-0.30.0/csv2ofx/mappings/rabobank.py +0 -31
  40. csv2ofx-0.30.0/csv2ofx/mappings/schwab.py +0 -19
  41. csv2ofx-0.30.0/csv2ofx/mappings/split_account.py +0 -18
  42. csv2ofx-0.30.0/csv2ofx/mappings/starling.py +0 -16
  43. csv2ofx-0.30.0/csv2ofx/mappings/stripe.py +0 -31
  44. csv2ofx-0.30.0/csv2ofx/mappings/ubs-ch-fr.py +0 -72
  45. csv2ofx-0.30.0/csv2ofx/mappings/ubs.py +0 -16
  46. csv2ofx-0.30.0/csv2ofx/mappings/xero.py +0 -14
  47. csv2ofx-0.30.0/csv2ofx/mappings/yodlee.py +0 -23
  48. csv2ofx-0.30.0/csv2ofx.egg-info/SOURCES.txt +0 -73
  49. csv2ofx-0.30.0/csv2ofx.egg-info/not-zip-safe +0 -1
  50. csv2ofx-0.30.0/dev-requirements.txt +0 -15
  51. csv2ofx-0.30.0/helpers/.DS_Store +0 -0
  52. csv2ofx-0.30.0/helpers/pippy +0 -61
  53. csv2ofx-0.30.0/pyproject.toml +0 -3
  54. csv2ofx-0.30.0/setup.cfg +0 -31
  55. csv2ofx-0.30.0/setup.py +0 -77
  56. csv2ofx-0.30.0/tests/.DS_Store +0 -0
  57. csv2ofx-0.30.0/tests/pylintrc +0 -254
  58. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/LICENSE +0 -0
  59. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/MANIFEST.in +0 -0
  60. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx/utils.py +0 -0
  61. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/dependency_links.txt +0 -0
  62. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/csv2ofx.egg-info/top_level.txt +0 -0
  63. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFX 2.1.1.pdf +0 -0
  64. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFXAudit.xls +0 -0
  65. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/OFX_Message_Support.doc +0 -0
  66. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification.html +0 -0
  67. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a.html +0 -0
  68. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_002.html +0 -0
  69. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_003.html +0 -0
  70. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_004.html +0 -0
  71. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/a_005.html +0 -0
  72. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/bootstrap.js +0 -0
  73. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/jquery.js +0 -0
  74. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/QIF Specification_files/sitecss.css +0 -0
  75. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/docs/qif-file-format.txt +0 -0
  76. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/check-stage +0 -0
  77. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/clean +0 -0
  78. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/srcdist +0 -0
  79. {csv2ofx-0.30.0 → csv2ofx-0.32.0}/helpers/wheel +0 -0
@@ -1,38 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: csv2ofx
3
- Version: 0.30.0
3
+ Version: 0.32.0
4
4
  Summary: converts a csv file of transactions to an ofx or qif file
5
- Home-page: https://github.com/reubano/csv2ofx
6
- Author: Reuben Cummings
7
- Author-email: reubano@gmail.com
8
- License: MIT
9
- Download-URL: https://github.com/reubano/csv2ofx/archive/v0.30.0.tar.gz
10
- Keywords: csv2ofx,converts,a,csv,file,of,transactions,to,an,ofx,or,qif,file
11
- Platform: MacOS X
12
- Platform: Windows
13
- Platform: Linux
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Development Status :: 4 - Beta
5
+ Author-email: Reuben Cummings <reubano@gmail.com>
6
+ Maintainer-email: "Jason R. Coombs" <jaraco@jaraco.com>
7
+ Project-URL: Source, https://github.com/reubano/csv2ofx
8
+ Classifier: Development Status :: 5 - Production/Stable
16
9
  Classifier: Natural Language :: English
17
10
  Classifier: Programming Language :: Python :: 3
18
11
  Classifier: Programming Language :: Python :: 3 :: Only
19
- Classifier: Programming Language :: Python :: 3.7
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
12
  Classifier: Programming Language :: Python :: Implementation :: CPython
23
13
  Classifier: Programming Language :: Python :: Implementation :: PyPy
24
14
  Classifier: Environment :: Console
25
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
16
  Classifier: Intended Audience :: Developers
27
- Classifier: Operating System :: POSIX :: Linux
28
- Classifier: Operating System :: MacOS :: MacOS X
29
- Classifier: Operating System :: Microsoft :: Windows
30
17
  Description-Content-Type: text/markdown
31
18
  License-File: LICENSE
19
+ Requires-Dist: python-dateutil<3.0.0,>=2.7.2
20
+ Requires-Dist: requests<3.0.0,>=2.18.4
21
+ Requires-Dist: meza<0.48.0,>=0.47.0
32
22
 
33
23
  # csv2ofx
34
24
 
35
- [![travis](https://img.shields.io/travis/reubano/csv2ofx/master.svg)](https://app.travis-ci.com/github/reubano/csv2ofx)
25
+ [![GHA](https://github.com/PROJECT_PATH/actions/workflows/main.yml/badge.svg)](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
36
26
  [![versions](https://img.shields.io/pypi/pyversions/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
37
27
  [![pypi](https://img.shields.io/pypi/v/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
38
28
 
@@ -112,21 +102,23 @@ usage: csv2ofx [options] <source> <dest>
112
102
  description: csv2ofx converts a csv file to ofx and qif
113
103
 
114
104
  positional arguments:
115
- source the source csv file (defaults to stdin)
116
- dest the output file (defaults to stdout)
105
+ source the source csv file (default: stdin)
106
+ dest the output file (default: stdout)
117
107
 
118
108
  optional arguments:
119
109
  -h, --help show this help message and exit
120
110
  -a TYPE, --account TYPE
121
111
  default account type 'CHECKING' for OFX and 'Bank' for QIF.
122
- -e DATE, --end DATE end date
112
+ -e DATE, --end DATE end date (default: today)
113
+ -B BALANCE, --ending-balance BALANCE
114
+ ending balance (default: None)
123
115
  -l LANGUAGE, --language LANGUAGE
124
- the language
116
+ the language (default: ENG)
125
117
  -s DATE, --start DATE
126
118
  the start date
127
119
  -y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
128
- -m MAPPING, --mapping MAPPING
129
- the account mapping
120
+ -m MAPPING_NAME, --mapping MAPPING_NAME
121
+ the account mapping (default: default)
130
122
  -x FILE_PATH, --custom FILE_PATH
131
123
  path to a custom mapping file
132
124
  -c FIELD_NAME, --collapse FIELD_NAME
@@ -134,16 +126,17 @@ optional arguments:
134
126
  -C ROWS, --chunksize ROWS
135
127
  number of rows to process at a time (default: 2 ** 14)
136
128
  -r ROWS, --first-row ROWS
137
- number of initial rows to skip (default: 0)
138
- -r ROWS, --last-row ROWS
139
- the final rows to process, negative values count from the end (default: inf)
129
+ the first row to process (zero based)
130
+ -R ROWS, --last-row ROWS
131
+ the last row to process (zero based, negative values count from the end)
140
132
  -O COLS, --first-col COLS
141
- number of initial cols to skip (default: 0)
133
+ the first column to process (zero based)
142
134
  -L, --list-mappings list the available mappings
143
135
  -V, --version show version and exit
144
136
  -q, --qif enables 'QIF' output instead of 'OFX'
137
+ -M, --ms-money enables MS Money compatible 'OFX' output
145
138
  -o, --overwrite overwrite destination file if it exists
146
- -D SERVER_DATE, --server-date SERVER_DATE
139
+ -D DATE, --server-date DATE
147
140
  OFX server date (default: source file mtime)
148
141
  -E ENCODING, --encoding ENCODING
149
142
  File encoding (default: utf-8)
@@ -175,6 +168,17 @@ optional arguments:
175
168
 
176
169
  csv2ofx -m yoodlee file.csv
177
170
 
171
+
172
+ #### Special cases
173
+
174
+ Some banks, like *UBS Switzerland*, may provide CSV exports that are not
175
+ readily tractable by csv2ofx because of extra header or trailing lines,
176
+ redundant or unwanted columns. These input files can be preprocessed with the
177
+ shipped `utilz/csvtrim` shell script. F.i., with mapping `ubs-ch-fr`:
178
+
179
+ csvtrim untrimmed.csv | csv2ofx -m ubs-ch-fr
180
+
181
+
178
182
  ## CUSTOMIZATION
179
183
 
180
184
  ### Code modification
@@ -239,6 +243,7 @@ attribute | description | default field | default value | example
239
243
  attribute | description | default value | example
240
244
  ----------|-------------|---------------|--------
241
245
  `has_header`|does the csv file have a header row|True
246
+ `custom_header`|header row to use (e.g. if not provided in csv)|None|["Account","Date","Amount"]
242
247
  `is_split`|does the csv file contain split (double entry) transactions|False
243
248
  `currency`|the currency ISO code|USD|GBP
244
249
  `delimiter`|the csv field delimiter|,|;
@@ -283,7 +288,7 @@ cd csv2ofx
283
288
  2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
284
289
 
285
290
  ```bash
286
- mkvirtualenv --no-site-packages csv2ofx
291
+ mkvirtualenv -i pkutils csv2ofx
287
292
  activate csv2ofx
288
293
  python setup.py develop
289
294
  pip install -r dev-requirements.txt
@@ -310,5 +315,3 @@ How to contribute a mapping:
310
315
  ## License
311
316
 
312
317
  csv2ofx is distributed under the [MIT License](http://opensource.org/licenses/MIT), the same as [meza](https://github.com/reubano/meza).
313
-
314
-
@@ -1,6 +1,6 @@
1
1
  # csv2ofx
2
2
 
3
- [![travis](https://img.shields.io/travis/reubano/csv2ofx/master.svg)](https://app.travis-ci.com/github/reubano/csv2ofx)
3
+ [![GHA](https://github.com/PROJECT_PATH/actions/workflows/main.yml/badge.svg)](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
4
4
  [![versions](https://img.shields.io/pypi/pyversions/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
5
5
  [![pypi](https://img.shields.io/pypi/v/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
6
6
 
@@ -80,21 +80,23 @@ 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 (defaults to stdin)
84
- dest the output file (defaults to stdout)
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
97
  -y, --dayfirst interpret the first value in ambiguous dates (e.g. 01/05/09) as the day
96
- -m MAPPING, --mapping MAPPING
97
- the account mapping
98
+ -m MAPPING_NAME, --mapping MAPPING_NAME
99
+ the account mapping (default: default)
98
100
  -x FILE_PATH, --custom FILE_PATH
99
101
  path to a custom mapping file
100
102
  -c FIELD_NAME, --collapse FIELD_NAME
@@ -102,16 +104,17 @@ optional arguments:
102
104
  -C ROWS, --chunksize ROWS
103
105
  number of rows to process at a time (default: 2 ** 14)
104
106
  -r ROWS, --first-row ROWS
105
- number of initial rows to skip (default: 0)
106
- -r ROWS, --last-row ROWS
107
- the final rows to process, negative values count from the end (default: inf)
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)
108
110
  -O COLS, --first-col COLS
109
- number of initial cols to skip (default: 0)
111
+ the first column to process (zero based)
110
112
  -L, --list-mappings list the available mappings
111
113
  -V, --version show version and exit
112
114
  -q, --qif enables 'QIF' output instead of 'OFX'
115
+ -M, --ms-money enables MS Money compatible 'OFX' output
113
116
  -o, --overwrite overwrite destination file if it exists
114
- -D SERVER_DATE, --server-date SERVER_DATE
117
+ -D DATE, --server-date DATE
115
118
  OFX server date (default: source file mtime)
116
119
  -E ENCODING, --encoding ENCODING
117
120
  File encoding (default: utf-8)
@@ -143,6 +146,17 @@ optional arguments:
143
146
 
144
147
  csv2ofx -m yoodlee file.csv
145
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
+
146
160
  ## CUSTOMIZATION
147
161
 
148
162
  ### Code modification
@@ -207,6 +221,7 @@ attribute | description | default field | default value | example
207
221
  attribute | description | default value | example
208
222
  ----------|-------------|---------------|--------
209
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"]
210
225
  `is_split`|does the csv file contain split (double entry) transactions|False
211
226
  `currency`|the currency ISO code|USD|GBP
212
227
  `delimiter`|the csv field delimiter|,|;
@@ -251,7 +266,7 @@ cd csv2ofx
251
266
  2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
252
267
 
253
268
  ```bash
254
- mkvirtualenv --no-site-packages csv2ofx
269
+ mkvirtualenv -i pkutils csv2ofx
255
270
  activate csv2ofx
256
271
  python setup.py develop
257
272
  pip install -r dev-requirements.txt
@@ -37,7 +37,7 @@ __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.30.0"
40
+ __version__ = "0.32.0"
41
41
  __license__ = "MIT"
42
42
  __copyright__ = "Copyright 2015 Reuben Cummings"
43
43
 
@@ -46,6 +46,12 @@ __copyright__ = "Copyright 2015 Reuben Cummings"
46
46
  md5 = lambda content: hashlib.md5(content.encode("utf-8")).hexdigest()
47
47
 
48
48
 
49
+ class BalanceError(Exception):
50
+ """Raised if no ending balance when MS Money compatible output requested"""
51
+
52
+ pass
53
+
54
+
49
55
  class Content(object): # pylint: disable=too-many-instance-attributes
50
56
  """A transaction holding object"""
51
57
 
@@ -76,6 +82,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
76
82
  self.parse_fmt = kwargs.get("parse_fmt")
77
83
  self.dayfirst = kwargs.get("dayfirst")
78
84
  self.filter = kwargs.get("filter")
85
+ self.ms_money = kwargs.get("ms_money")
79
86
  self.split_account = None
80
87
  self.inv_split_account = None
81
88
  self.id = None
@@ -226,7 +233,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
226
233
  ... 'split_account': 'Checking', 'type': 'DEBIT',
227
234
  ... 'category': '', 'amount': Decimal('-1000.00'),
228
235
  ... 'memo': 'description notes', 'inv_split_account': None,
229
- ... 'x_action': ''}
236
+ ... 'x_action': '', 'balance': None}
230
237
  True
231
238
  """
232
239
  account = self.get("account", trxn)
@@ -251,6 +258,9 @@ class Content(object): # pylint: disable=too-many-instance-attributes
251
258
  symbol = self.get("symbol", trxn, "")
252
259
  price = Decimal(self.get("price", trxn, 0))
253
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)
254
264
 
255
265
  if invest:
256
266
  amount = abs(amount)
@@ -288,6 +298,7 @@ class Content(object): # pylint: disable=too-many-instance-attributes
288
298
  "id": self.get("id", trxn, check_num) or md5(details),
289
299
  "check_num": check_num,
290
300
  "type": _type,
301
+ "balance": balance,
291
302
  }
292
303
 
293
304
  def gen_trxns(self, groups, collapse=False):
@@ -16,13 +16,13 @@ Examples:
16
16
  Attributes:
17
17
  ENCODING (str): Default file encoding.
18
18
  """
19
+
19
20
  import time
20
21
  import itertools as it
21
22
  import traceback
22
23
 
23
24
  from sys import stdin, stdout, exit
24
- from importlib import import_module
25
- from imp import find_module, load_module
25
+ from importlib import import_module, util
26
26
  from pkgutil import iter_modules
27
27
  from operator import itemgetter
28
28
  from os import path as p
@@ -41,7 +41,7 @@ from builtins import *
41
41
  from dateutil.parser import parse
42
42
  from meza.io import read_csv, IterStringIO, write
43
43
 
44
- from . import utils
44
+ from . import BalanceError, utils
45
45
  from .ofx import OFX
46
46
  from .qif import QIF
47
47
 
@@ -77,6 +77,13 @@ parser.add_argument(
77
77
  help="end date (default: today)",
78
78
  default=str(dt.now()),
79
79
  )
80
+ parser.add_argument(
81
+ "-B",
82
+ "--ending-balance",
83
+ metavar="BALANCE",
84
+ type=float,
85
+ help="ending balance (default: None)",
86
+ )
80
87
  parser.add_argument(
81
88
  "-l", "--language", help="the language (default: ENG)", default="ENG"
82
89
  )
@@ -104,8 +111,7 @@ parser.add_argument(
104
111
  "--collapse",
105
112
  metavar="FIELD_NAME",
106
113
  help=(
107
- "field used to combine transactions within a split for double entry "
108
- "statements"
114
+ "field used to combine transactions within a split for double entry statements"
109
115
  ),
110
116
  )
111
117
  parser.add_argument(
@@ -157,6 +163,13 @@ parser.add_argument(
157
163
  action="store_true",
158
164
  default=False,
159
165
  )
166
+ parser.add_argument(
167
+ "-M",
168
+ "--ms-money",
169
+ help="enables MS Money compatible 'OFX' output",
170
+ action="store_true",
171
+ default=False,
172
+ )
160
173
  parser.add_argument(
161
174
  "-o",
162
175
  "--overwrite",
@@ -205,8 +218,9 @@ def run(): # noqa: C901
205
218
 
206
219
  if args.custom:
207
220
  name = p.splitext(p.split(args.custom)[1])[0]
208
- found = find_module(name, [p.dirname(p.abspath(args.custom))])
209
- module = load_module(name, *found)
221
+ spec = util.spec_from_file_location(name, args.custom)
222
+ module = util.module_from_spec(spec)
223
+ spec.loader.exec_module(module)
210
224
  else:
211
225
  module = import_module("csv2ofx.mappings.%s" % args.mapping)
212
226
 
@@ -216,6 +230,7 @@ def run(): # noqa: C901
216
230
  "def_type": args.account_type or "Bank" if args.qif else "CHECKING",
217
231
  "start": parse(args.start, dayfirst=args.dayfirst) if args.start else None,
218
232
  "end": parse(args.end, dayfirst=args.dayfirst) if args.end else None,
233
+ "ms_money": args.ms_money,
219
234
  }
220
235
 
221
236
  cont = QIF(mapping, **okwargs) if args.qif else OFX(mapping, **okwargs)
@@ -223,6 +238,7 @@ def run(): # noqa: C901
223
238
 
224
239
  ckwargs = {
225
240
  "has_header": cont.has_header,
241
+ "custom_header": getattr(cont, "custom_header", None),
226
242
  "delimiter": mapping.get("delimiter", ","),
227
243
  "first_row": mapping.get("first_row", args.first_row),
228
244
  "last_row": mapping.get("last_row", args.last_row),
@@ -248,7 +264,7 @@ def run(): # noqa: C901
248
264
  server_date = dt.fromtimestamp(mtime)
249
265
 
250
266
  header = cont.header(date=server_date, language=args.language)
251
- footer = cont.footer(date=server_date)
267
+ footer = cont.footer(date=server_date, balance=args.ending_balance)
252
268
  filtered = filter(None, [header, body, footer])
253
269
  content = it.chain.from_iterable(filtered)
254
270
  kwargs = {
@@ -277,6 +293,8 @@ def run(): # noqa: C901
277
293
  # csv2ofx called with no arguments or broken mapping
278
294
  msg = "Possible mapping problem: %s. " % str(err)
279
295
  parser.print_help()
296
+ except BalanceError as err:
297
+ msg = "%s. Try again with `--ending-balance` option." % err
280
298
  except Exception: # pylint: disable=broad-except
281
299
  msg = 1
282
300
  traceback.print_exc()