Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans IJntema committed Jan 28, 2023
1 parent 4eeda58 commit f196f7d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 48 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ With a bit of luck, you can use an existing parser. Or copy and extend.
* python > 3.x (tested with 3.7.3)

## Versions
1.0.3:
* Rabobank beleggen (investments) changed output format CSV

1.0.2:
* Fix error processing when command line is empty
Expand Down
5 changes: 5 additions & 0 deletions banks/ing-checking.def
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ING Betaal rekening (Checking)
# Download CSV with semicolon
# Download in DUTCH language


# There is 1 header
SKIPHEADERS 1

Expand Down
23 changes: 13 additions & 10 deletions banks/rabobank-beleggen.def
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Rabobank Beleggen
# Update for v1.0.3 (Jan 2023)
# Only fund transactions are converted;
# All cash amounts (dividend etc) will be processed via PARENTACCOUNT

# Number of lines at start of csv file and will be skipped
# There is 1 header
Expand All @@ -18,7 +21,7 @@ FINGERPRINTREGEX ^.*Portefeuille$
CSVPARSER readRabobankBeleggenCSV

# To link this investment account to its checking account
PARENTACCOUNT nl33rabo0305060678
PARENTACCOUNT NL12ABNA1234567890

COL_DATE 2

Expand All @@ -31,15 +34,15 @@ COL_IBAN 0

COL_MEMO 3
COL_SHARENAME 1
COL_ISIN 10
COL_QUANTITY 4
COL_PRICE 5
COL_PRICECURRENCY 6
COL_COMMISSION 7
COL_AMOUNT 8
COL_TOTAL 9
#COL_TIME 11
COL_STOCKMARKET 12
COL_ISIN 11
COL_QUANTITY 5
COL_PRICE 6
COL_PRICECURRENCY 7
COL_COMMISSION 8
COL_AMOUNT 9
COL_TOTAL 10
#COL_TIME 12
COL_STOCKMARKET 13



2 changes: 1 addition & 1 deletion csv2qif.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

__version__ = "1.0.2"
__version__ = "1.0.3"


import os
Expand Down
45 changes: 27 additions & 18 deletions log.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
#!/usr/bin/python3

"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
DESCRIPTION
Expand All @@ -34,16 +17,42 @@
====================================================================
import __main__
import logging
import os
script=os.path.basename(__main__.__file__)
script=os.path.splitext(script)[0]
logger = logging.getLogger(script + "." + __name__)
====================================================================
V1.1.0
31-10-2021
Disable syslog handler for non linux platforms
V0.1:
- initial version
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

__version__ = "1.1.0"
__author__ = "Hans IJntema"
__license__ = "GPLv3"



# ------------------------------------------------------------------------------------
# Logging
Expand Down Expand Up @@ -75,7 +84,6 @@
c_handler.setFormatter(c_format)
logger.addHandler(c_handler)


# Syslog
if sys.platform == "linux":
s_handler = logging.handlers.SysLogHandler( address=('/dev/log') )
Expand All @@ -85,6 +93,7 @@
s_handler.setFormatter(s_format)
logger.addHandler(s_handler)


# File
# Test if /dev/shm is writable otherwise use /tmp
try:
Expand Down
40 changes: 21 additions & 19 deletions parsebank.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def sanitizeString(line, lowercase=False):
Removes duplicate spaces
Optionally, converts string to lower case
Keyword arguments:
:param str line
:param bool lowercase
:param str line:
:param bool lowercase:
:return sanitized line
:rtype str
"""

line = line.lstrip()
Expand All @@ -72,19 +72,23 @@ def convertDecimalComma(amount):
Convert decimal comma to decimal point notation
25.400,05 --> 25400.05
Keyword arguments:
:param str amount
:return amount
Removes any non digits (as Rabobank certificaten add %)
:param str amount: amount to be converted
:return sanitized amount:
:rtype str
"""

# remove decimal point
amount = amount.replace(".", "", 1)
__amount = amount.replace(".", "", 1)

# replace decimal comma with decimal point
amount = amount.replace(",", ".", 1)
__amount = __amount.replace(",", ".", 1)

# remove keep all digits, decimal point and minus; remove all others
__amount = re.sub("[^\d|.|-]", "", __amount)

return amount
return __amount


def queryBankDefFiles():
Expand Down Expand Up @@ -190,8 +194,7 @@ def readRabobankCheckingCSV(csvfile_, definitionfile_, csvlist):
"""
Parse Rabobank Checking/Regular account CSV file
Keyword arguments:
:param str csvFile_: Path + Filename to bank csv file
:param str csvfile_: Path + Filename to bank csv file
:param str definitionfile_:Path + Filename to definition file of bank
:param list of dictionaries csvlist: list of dictionaries of parsed transactions
"""
Expand Down Expand Up @@ -263,7 +266,7 @@ def readINGCheckingCSV(csvfile_, definitionfile_, csvlist):
Parse ING Checking/Regular account CSV file
Keyword arguments:
:param str csvFile_: Path + Filename to bank csv file
:param str csvfile_: Path + Filename to bank csv file
:param str definitionfile_:Path + Filename to definition file of bank
:param list of dictionaries csvlist: list of dictionaries of parsed transactions csvlist
"""
Expand Down Expand Up @@ -335,7 +338,7 @@ def readDeGiroTransactionsCSV(csvfile_, definitionfile_, csvlist):
Dividends and costs are via DeGiro ACCOUNTS CSV file
Keyword arguments:
:param str csvFile_: Path + Filename to bank csv file
:param str csvfile_: Path + Filename to bank csv file
:param str definitionfile_:Path + Filename to definition file of bank
:param list of dictionaries csvlist: list of dictionaries of parsed transactions csvlist
"""
Expand Down Expand Up @@ -412,7 +415,8 @@ def readDeGiroTransactionsCSV(csvfile_, definitionfile_, csvlist):
# positive number == expense
try:
row[commission_] = str(-1.0*(float(row[commission_])))
except: None
except:
None

# It seems that:
# amount = price * quantity + commission
Expand Down Expand Up @@ -449,7 +453,7 @@ def readDeGiroAccountCSV(csvfile_, definitionfile_, csvlist):
It is not 100% perfect...typically a few dimes off....DeGiro has IMO inconsistent csv file structure
Keyword arguments:
:param str csvFile_: Path + Filename to bank csv file
:param str csvfile_: Path + Filename to bank csv file
:param str definitionfile_:Path + Filename to definition file of bank
:param list of dictionaries csvlist: list of dictionaries of parsed transactions csvlist
"""
Expand Down Expand Up @@ -545,7 +549,7 @@ def readRabobankBeleggenCSV(csvfile_, definitionfile_, csvlist):
does not have to be true;
Keyword arguments:
:param str csvFile_: Path + Filename to bank csv file
:param str csvfile_: Path + Filename to bank csv file
:param str definitionfile_:Path + Filename to definition file of bank
:param list of dictionaries csvlist: list of dictionaries of parsed transactions csvlist
"""
Expand All @@ -571,7 +575,7 @@ def readRabobankBeleggenCSV(csvfile_, definitionfile_, csvlist):
transfer_amount_ = int(definition_dict['COL_TOTAL']) # Total amount of transaction
#currency_ = int(definition_dict['COL_PRICECURRENCY'])

# Rabobank beleggen csv files truncates last comlumns when empty
# Rabobank beleggen csv files truncates last colomns when empty
# Rewrite csv file with constant nrof columns per row
statement = list( csv.reader(fileinput.input(files=(csvfile_)), delimiter=delimiter_, quotechar=quotechar_) )
maxFields = max( len(i) for i in statement ) # how many fields?
Expand Down Expand Up @@ -620,8 +624,6 @@ def readRabobankBeleggenCSV(csvfile_, definitionfile_, csvlist):
if re.match( "^.*koop internet.*$", row[memo_].lower() ) or \
re.match("^.*verkoop internet.*$", row[memo_].lower()):

# Calculate commission from difference transfer amount and value of purchase
# Round to 2 digits
a = abs(float(row[transfer_amount_]))
b = abs(float(row[amount_]))
row[commission_] = format( abs(a - b), '.2f')
Expand Down
Empty file modified readme.txt
100644 → 100755
Empty file.

0 comments on commit f196f7d

Please sign in to comment.