csv2ofx 0.30.0__tar.gz → 0.31.1__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 (134) hide show
  1. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/MANIFEST.in +1 -1
  2. {csv2ofx-0.30.0/csv2ofx.egg-info → csv2ofx-0.31.1}/PKG-INFO +48 -18
  3. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/README.md +28 -13
  4. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/__init__.py +13 -2
  5. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/main.py +26 -8
  6. csv2ofx-0.31.1/csv2ofx/mappings/amazon.py +61 -0
  7. csv2ofx-0.31.1/csv2ofx/mappings/ingesp.py +70 -0
  8. csv2ofx-0.31.1/csv2ofx/mappings/schwabchecking.py +67 -0
  9. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/ubs-ch-fr.py +14 -9
  10. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/ofx.py +280 -16
  11. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/qif.py +2 -1
  12. {csv2ofx-0.30.0 → csv2ofx-0.31.1/csv2ofx.egg-info}/PKG-INFO +48 -18
  13. csv2ofx-0.31.1/csv2ofx.egg-info/SOURCES.txt +124 -0
  14. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx.egg-info/requires.txt +1 -1
  15. csv2ofx-0.31.1/data/converted/amazon.ofx +51 -0
  16. csv2ofx-0.31.1/data/converted/creditunion.qif +45 -0
  17. csv2ofx-0.31.1/data/converted/default.ofx +111 -0
  18. csv2ofx-0.31.1/data/converted/default.qif +50 -0
  19. csv2ofx-0.31.1/data/converted/default_w_splits.ofx +167 -0
  20. csv2ofx-0.31.1/data/converted/default_w_splits.qif +66 -0
  21. csv2ofx-0.31.1/data/converted/gls.ofx +43 -0
  22. csv2ofx-0.31.1/data/converted/ingesp.ofx +115 -0
  23. csv2ofx-0.31.1/data/converted/mint.ofx +95 -0
  24. csv2ofx-0.31.1/data/converted/mint.qif +42 -0
  25. csv2ofx-0.31.1/data/converted/mint_alt.qif +21 -0
  26. csv2ofx-0.31.1/data/converted/mint_extra.qif +34 -0
  27. csv2ofx-0.31.1/data/converted/outbank.ofx +67 -0
  28. csv2ofx-0.31.1/data/converted/pcmastercard.ofx +47 -0
  29. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case1.ofx +75 -0
  30. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case2.ofx +71 -0
  31. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case3.ofx +75 -0
  32. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case4.ofx +75 -0
  33. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case5.ofx +75 -0
  34. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case6.ofx +75 -0
  35. csv2ofx-0.31.1/data/converted/schwab-checking-baltest-case7.ofx +53 -0
  36. csv2ofx-0.31.1/data/converted/schwab-checking-msmoney.ofx +79 -0
  37. csv2ofx-0.31.1/data/converted/schwab-checking.ofx +75 -0
  38. csv2ofx-0.31.1/data/converted/stripe-all.ofx +75 -0
  39. csv2ofx-0.31.1/data/converted/stripe-all.qif +30 -0
  40. csv2ofx-0.31.1/data/converted/stripe-default.ofx +75 -0
  41. csv2ofx-0.31.1/data/converted/stripe-default.qif +26 -0
  42. csv2ofx-0.31.1/data/converted/ubs-ch-fr.qif +25 -0
  43. csv2ofx-0.31.1/data/converted/xero.qif +64 -0
  44. csv2ofx-0.31.1/data/example/investment_example.qif +24 -0
  45. csv2ofx-0.31.1/data/example/transaction_example.ofx +46 -0
  46. csv2ofx-0.31.1/data/example/transfer_example.ofx +41 -0
  47. csv2ofx-0.31.1/data/test/amazon.csv +5 -0
  48. csv2ofx-0.31.1/data/test/capitalone.csv +3 -0
  49. csv2ofx-0.31.1/data/test/creditunion.csv +1 -0
  50. csv2ofx-0.31.1/data/test/default.csv +9 -0
  51. csv2ofx-0.31.1/data/test/gls.csv +2 -0
  52. csv2ofx-0.31.1/data/test/ingesp.csv +11 -0
  53. csv2ofx-0.31.1/data/test/mint.csv +1 -0
  54. csv2ofx-0.31.1/data/test/mint_extra.csv +1 -0
  55. csv2ofx-0.31.1/data/test/mint_headerless.csv +1 -0
  56. csv2ofx-0.31.1/data/test/outbank.csv +5 -0
  57. csv2ofx-0.31.1/data/test/pcmastercard.csv +3 -0
  58. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case1.csv +8 -0
  59. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case2.csv +8 -0
  60. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case3.csv +8 -0
  61. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case4.csv +8 -0
  62. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case5.csv +8 -0
  63. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case6.csv +8 -0
  64. csv2ofx-0.31.1/data/test/schwab-checking-baltest-case7.csv +6 -0
  65. csv2ofx-0.31.1/data/test/schwab-checking.csv +8 -0
  66. csv2ofx-0.31.1/data/test/stripe-all.csv +6 -0
  67. csv2ofx-0.31.1/data/test/stripe-default.csv +6 -0
  68. csv2ofx-0.31.1/data/test/ubs-ch-fr_trimmed.csv +4 -0
  69. csv2ofx-0.31.1/data/test/xero.csv +1 -0
  70. csv2ofx-0.31.1/dev-requirements.txt +10 -0
  71. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/requirements.txt +1 -1
  72. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/setup.cfg +4 -0
  73. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/tests/test.py +61 -3
  74. csv2ofx-0.30.0/csv2ofx/mappings/bnp.py +0 -17
  75. csv2ofx-0.30.0/csv2ofx/mappings/paychex.py +0 -24
  76. csv2ofx-0.30.0/csv2ofx/mappings/schwab.py +0 -19
  77. csv2ofx-0.30.0/csv2ofx.egg-info/SOURCES.txt +0 -73
  78. csv2ofx-0.30.0/dev-requirements.txt +0 -15
  79. csv2ofx-0.30.0/helpers/.DS_Store +0 -0
  80. csv2ofx-0.30.0/helpers/pippy +0 -61
  81. csv2ofx-0.30.0/tests/.DS_Store +0 -0
  82. csv2ofx-0.30.0/tests/pylintrc +0 -254
  83. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/LICENSE +0 -0
  84. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/bin/csv2ofx +0 -0
  85. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/__init__.py +0 -0
  86. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/abnamro.py +0 -0
  87. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/boursorama.py +0 -0
  88. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/capitalone.py +0 -0
  89. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/creditunion.py +0 -0
  90. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/custom.py +0 -0
  91. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/default.py +0 -0
  92. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/eqbank.py +0 -0
  93. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/exim.py +0 -0
  94. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/gls.py +0 -0
  95. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/ingdirect.py +0 -0
  96. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/mdb.py +0 -0
  97. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/mint.py +0 -0
  98. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/mint_extra.py +0 -0
  99. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/mint_headerless.py +0 -0
  100. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/mintapi.py +0 -0
  101. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/msmoneyreport.py +0 -0
  102. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/n26.py +0 -0
  103. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/outbank.py +0 -0
  104. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/pcmastercard.py +0 -0
  105. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/rabobank.py +0 -0
  106. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/split_account.py +0 -0
  107. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/starling.py +0 -0
  108. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/stripe.py +0 -0
  109. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/ubs.py +0 -0
  110. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/xero.py +0 -0
  111. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/mappings/yodlee.py +0 -0
  112. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx/utils.py +0 -0
  113. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx.egg-info/dependency_links.txt +0 -0
  114. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx.egg-info/not-zip-safe +0 -0
  115. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/csv2ofx.egg-info/top_level.txt +0 -0
  116. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/OFX 2.1.1.pdf +0 -0
  117. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/OFXAudit.xls +0 -0
  118. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/OFX_Message_Support.doc +0 -0
  119. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification.html +0 -0
  120. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/a.html +0 -0
  121. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/a_002.html +0 -0
  122. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/a_003.html +0 -0
  123. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/a_004.html +0 -0
  124. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/a_005.html +0 -0
  125. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/bootstrap.js +0 -0
  126. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/jquery.js +0 -0
  127. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/QIF Specification_files/sitecss.css +0 -0
  128. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/docs/qif-file-format.txt +0 -0
  129. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/helpers/check-stage +0 -0
  130. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/helpers/clean +0 -0
  131. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/helpers/srcdist +0 -0
  132. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/helpers/wheel +0 -0
  133. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/pyproject.toml +0 -0
  134. {csv2ofx-0.30.0 → csv2ofx-0.31.1}/setup.py +0 -0
@@ -1,4 +1,4 @@
1
- recursive-include csv2ofx/data *
1
+ recursive-include data *
2
2
  recursive-include tests *
3
3
  recursive-include helpers *
4
4
  recursive-include docs *
@@ -1,12 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: csv2ofx
3
- Version: 0.30.0
3
+ Version: 0.31.1
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.1.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.30.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
- [![travis](https://img.shields.io/travis/reubano/csv2ofx/master.svg)](https://app.travis-ci.com/github/reubano/csv2ofx)
52
+ [![GHA](https://github.com/PROJECT_PATH/actions/workflows/main.yml/badge.svg)](https://github.com/PROJECT_PATH/actions?query=workflow%3A%22tests%22)
36
53
  [![versions](https://img.shields.io/pypi/pyversions/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
37
54
  [![pypi](https://img.shields.io/pypi/v/csv2ofx.svg)](https://pypi.python.org/pypi/csv2ofx)
38
55
 
@@ -112,21 +129,23 @@ 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 (defaults to stdin)
116
- dest the output file (defaults to stdout)
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
146
  -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
147
+ -m MAPPING_NAME, --mapping MAPPING_NAME
148
+ the account mapping (default: default)
130
149
  -x FILE_PATH, --custom FILE_PATH
131
150
  path to a custom mapping file
132
151
  -c FIELD_NAME, --collapse FIELD_NAME
@@ -134,16 +153,17 @@ optional arguments:
134
153
  -C ROWS, --chunksize ROWS
135
154
  number of rows to process at a time (default: 2 ** 14)
136
155
  -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)
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)
140
159
  -O COLS, --first-col COLS
141
- number of initial cols to skip (default: 0)
160
+ the first column to process (zero based)
142
161
  -L, --list-mappings list the available mappings
143
162
  -V, --version show version and exit
144
163
  -q, --qif enables 'QIF' output instead of 'OFX'
164
+ -M, --ms-money enables MS Money compatible 'OFX' output
145
165
  -o, --overwrite overwrite destination file if it exists
146
- -D SERVER_DATE, --server-date SERVER_DATE
166
+ -D DATE, --server-date DATE
147
167
  OFX server date (default: source file mtime)
148
168
  -E ENCODING, --encoding ENCODING
149
169
  File encoding (default: utf-8)
@@ -175,6 +195,17 @@ optional arguments:
175
195
 
176
196
  csv2ofx -m yoodlee file.csv
177
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
+
178
209
  ## CUSTOMIZATION
179
210
 
180
211
  ### Code modification
@@ -239,6 +270,7 @@ attribute | description | default field | default value | example
239
270
  attribute | description | default value | example
240
271
  ----------|-------------|---------------|--------
241
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"]
242
274
  `is_split`|does the csv file contain split (double entry) transactions|False
243
275
  `currency`|the currency ISO code|USD|GBP
244
276
  `delimiter`|the csv field delimiter|,|;
@@ -283,7 +315,7 @@ cd csv2ofx
283
315
  2. Setup a new [virtualenv](http://www.virtualenv.org/en/latest/index.html)
284
316
 
285
317
  ```bash
286
- mkvirtualenv --no-site-packages csv2ofx
318
+ mkvirtualenv -i pkutils csv2ofx
287
319
  activate csv2ofx
288
320
  python setup.py develop
289
321
  pip install -r dev-requirements.txt
@@ -310,5 +342,3 @@ How to contribute a mapping:
310
342
  ## License
311
343
 
312
344
  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.31.1"
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()
@@ -0,0 +1,61 @@
1
+ """
2
+ Import transactions from Amazon Order History
3
+ as exported by Amazon Order History Reporter
4
+ (https://chrome.google.com/webstore/detail/amazon-order-history-repo/mgkilgclilajckgnedgjgnfdokkgnibi).
5
+
6
+ Honors some environment variables:
7
+
8
+ - ``AMAZON_INCLUDE_CARDS``: comma-separated last-four digits
9
+ of cards or payment methods to include in the output. If not
10
+ supplied, defaults to all cards.
11
+ - ``AMAZON_EXCLUDE_CARDS``: comma-separated last-four digits
12
+ of cards or payment methods to exclude in the output (supersedes
13
+ include).
14
+ - ``AMAZON_PURCHASES_ACCOUNT``: The OFX "account id" to use.
15
+ Financial tools will use this account ID to associated with an
16
+ account. If unspecified, defaults to "100000001".
17
+ """
18
+
19
+ import os
20
+ import functools
21
+ from operator import itemgetter
22
+
23
+
24
+ All = ['']
25
+ """
26
+ A special value matching all cards.
27
+ """
28
+
29
+
30
+ @functools.lru_cache()
31
+ def exclude_cards():
32
+ setting = os.environ.get('AMAZON_EXCLUDE_CARDS', None)
33
+ return setting.split(',') if setting else []
34
+
35
+
36
+ @functools.lru_cache()
37
+ def include_cards():
38
+ setting = os.environ.get('AMAZON_INCLUDE_CARDS', None)
39
+ return setting.split(',') if setting else All
40
+
41
+
42
+ def filter_payment(row):
43
+ include = any(card in row['payments'] for card in include_cards())
44
+ exclude = any(card in row['payments'] for card in exclude_cards())
45
+ return include and not exclude
46
+
47
+
48
+ mapping = {
49
+ 'has_header': True,
50
+ 'delimiter': ',',
51
+ 'bank': 'Amazon Purchases',
52
+ 'account_id': os.environ.get('AMAZON_PURCHASES_ACCOUNT', '100000001'),
53
+ 'date': itemgetter('date'),
54
+ 'amount': itemgetter('total'),
55
+ 'payee': 'Amazon',
56
+ 'desc': itemgetter('items'),
57
+ 'id': itemgetter('order id'),
58
+ 'type': 'DEBIT',
59
+ 'last_row': -1,
60
+ 'filter': filter_payment,
61
+ }
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim: sw=4:ts=4:expandtab
3
+ # pylint: disable=invalid-name
4
+ """
5
+ csv2ofx.mappings.ingdirect
6
+ ~~~~~~~~~~~~~~~~~~~~~~~~
7
+
8
+ Provides a mapping for transactions obtained via ING Direct
9
+ (Spanish bank)
10
+ """
11
+ from operator import itemgetter
12
+ import json
13
+ import hashlib
14
+
15
+
16
+ def find_type(transaction):
17
+ amount = float(transaction.get("amount"))
18
+ return "credit" if amount > 0 else "debit"
19
+
20
+
21
+ def gen_transaction_id(transaction):
22
+ hasher = hashlib.sha256()
23
+ stringified = json.dumps(transaction).encode("utf-8")
24
+ hasher.update(stringified)
25
+ return hasher.hexdigest()
26
+
27
+
28
+ def get_payee(transaction):
29
+ cadena = transaction.get('desc')
30
+ subcadenas = ['Abono por campaña', 'Devolución Tarjeta',
31
+ 'Nomina recibida', 'Traspaso recibido', 'Pago en',
32
+ 'Recibo', 'Reintegro efectivo', 'Transferencia Bizum emitida',
33
+ 'Transferencia emitida a', 'Transferencia recibida de']
34
+ for subcadena in subcadenas:
35
+ if subcadena in cadena:
36
+ payee = cadena.replace(subcadena, '')
37
+ break
38
+ else:
39
+ payee = cadena
40
+ return payee
41
+
42
+
43
+ def get_transaction_type(transaction):
44
+ cadena = transaction.get('desc')
45
+ subcadenas = ['Abono por campaña', 'Devolución Tarjeta',
46
+ 'Nomina recibida', 'Traspaso recibido', 'Pago en',
47
+ 'Recibo', 'Reintegro efectivo', 'Transferencia Bizum emitida',
48
+ 'Transferencia emitida a', 'Transferencia recibida de']
49
+ for subcadena in subcadenas:
50
+ if subcadena in cadena:
51
+ notes = subcadena
52
+ return notes
53
+
54
+
55
+ mapping = {
56
+ "has_header": True,
57
+ "is_split": False,
58
+ "bank": "ING",
59
+ "currency": "EUR",
60
+ "delimiter": ",",
61
+ "account": "ING checking",
62
+ "type": find_type,
63
+ "date": itemgetter("date"),
64
+ "amount": itemgetter("amount"),
65
+ "payee": get_payee,
66
+ # 'desc': get_transaction_type,
67
+ "class": itemgetter("class"),
68
+ "id": gen_transaction_id,
69
+ }
70
+
@@ -0,0 +1,67 @@
1
+ from __future__ import (
2
+ absolute_import, division, print_function, unicode_literals)
3
+
4
+ from operator import itemgetter
5
+ import re
6
+
7
+ # Default value if account_id not found in header rows.
8
+ schwab_account_id = "12345"
9
+
10
+
11
+ def is_real(transaction):
12
+ # Filter-out header line & lines that only have one column
13
+ type = transaction.get('Type')
14
+ return type and (type != "Type")
15
+
16
+
17
+ def schwab_filter(transaction):
18
+ if is_real(transaction):
19
+ return True
20
+
21
+ # Sanity check header row in CSV matches custom_header
22
+ line = transaction.get(mapping["custom_header"][0])
23
+ if line in mapping["custom_header"]:
24
+ for column in mapping["custom_header"]:
25
+ found_col = transaction.get(column)
26
+ if found_col != column:
27
+ raise ValueError("Header row mismatch (expected: '" + column +
28
+ "', found: '" + found_col + "')")
29
+
30
+ # Look for account_id in one of the lines being filtered out
31
+ global schwab_account_id
32
+ match = re.search(r'^Transactions for .* account (\.*\d*) as of', line)
33
+ if match:
34
+ schwab_account_id = match.group(1)
35
+ return False
36
+
37
+
38
+ def get_account_id(transaction):
39
+ global schwab_account_id
40
+ return schwab_account_id
41
+
42
+
43
+ mapping = {
44
+ # Technically Schwab Bank CSVs do have a header, but we want to extract
45
+ # the account_id from the line that comes before the header, so we use
46
+ # custom_header instead of parsing it from the second line of the CSV.
47
+ 'custom_header': ["Date","Type","Check #","Description","Withdrawal (-)",
48
+ "Deposit (+)","RunningBalance"],
49
+ 'has_header': False,
50
+ 'filter': schwab_filter,
51
+ 'is_split': False,
52
+ 'bank': 'Charles Schwab Bank, N.A.',
53
+ 'bank_id': '121202211',
54
+ 'account_id': get_account_id,
55
+ 'currency': 'USD',
56
+ 'account': 'Charles Schwab Checking',
57
+ # Schwab Bank includes three lines of text in their CSV which otherwise
58
+ # break date parsing. Filtering by lines with no "Type" (and faking out
59
+ # the date for those lines) avoids the problem.
60
+ 'date': lambda tr: tr.get('Date') if is_real(tr) else "1-1-1970",
61
+ 'check_num': itemgetter('Check #'),
62
+ 'payee': itemgetter('Description'),
63
+ 'desc': itemgetter('Description'),
64
+ 'type': lambda tr: 'debit' if tr.get('Withdrawal (-)') != '' else 'credit',
65
+ 'amount': lambda tr: tr.get('Deposit (+)') or tr.get('Withdrawal (-)'),
66
+ 'balance': itemgetter('RunningBalance'),
67
+ }
@@ -23,10 +23,10 @@ tricky:
23
23
  """
24
24
  from operator import itemgetter
25
25
 
26
- # Financial numbers are expressed as "2'045.56" -- TO-DO switch to Babel?
26
+ # Financial numbers are expressed as "2'045.56" in de/fr/it_CH (utf8 has some
27
+ # glitches, so we go for the default one)
27
28
  import locale
28
-
29
- locale.setlocale(locale.LC_ALL, "fr_CH.UTF-8")
29
+ locale.setlocale(locale.LC_NUMERIC, 'fr_CH')
30
30
 
31
31
  __author__ = 'Marco "sphakka" Poleggi'
32
32
 
@@ -38,13 +38,18 @@ def fixdate(ds):
38
38
  return ".".join((dmy[1], dmy[0], dmy[2]))
39
39
 
40
40
 
41
- def map_desc(tr):
42
- description = tr["Description 2"] or tr["Description 1"]
43
- return description + (": " + tr["Description 3"] if tr["Description 3"] else "")
41
+ def map_descr(tr):
42
+ descr = tr["Description 2"] or tr["Description 1"]
43
+ return descr + (": " + tr["Description 3"] if tr["Description 3"] else "")
44
+
45
+
46
+ def map_class(tr):
47
+ clss = tr["Description 1"]
48
+ return clss + (": " + tr["Description 2"] if tr["Description 2"] else "")
44
49
 
45
50
 
46
51
  def map_payee(tr):
47
- return tr["Description 3"] if tr.get("Débit") != "" else tr["Description 2"]
52
+ return tr["Description 3"] if tr.get("Débit") else tr["Description 2"]
48
53
 
49
54
 
50
55
  mapping = {
@@ -60,12 +65,12 @@ mapping = {
60
65
  "amount": lambda tr: locale.atof(tr["Débit"] or tr["Crédit"]),
61
66
  # debits show _your_ notes in "Desc 2", whereas credits report the
62
67
  # _payee_. Thus a better "class" value comes from "Desc 1" + "Desc 2"
63
- "class": lambda tr: tr["Description 1"] + (": " + tr["Description 2"] or ""),
68
+ "class": map_class,
64
69
  "notes": itemgetter("Description 2"),
65
70
  # switch day/month (maybe file a bug: always inverted when ambiguous like
66
71
  # '01.02.2018')
67
72
  "date": lambda tr: fixdate(tr["Date de valeur"]),
68
- "desc": map_desc,
73
+ "desc": map_descr,
69
74
  "payee": map_payee,
70
75
  "check_num": itemgetter("N° de transaction"),
71
76
  "balance": lambda tr: locale.atof(tr["Solde"]),