Skip to content

Instantly share code, notes, and snippets.

@johannes-staehlin
Created September 16, 2016 19:07
Show Gist options
  • Save johannes-staehlin/ecdd0c0dcf4f076d29f85ff19d457237 to your computer and use it in GitHub Desktop.
Save johannes-staehlin/ecdd0c0dcf4f076d29f85ff19d457237 to your computer and use it in GitHub Desktop.
Regex zum extrahieren der Umsatzdaten von Barclaycard. Kann verwendet werden um die Umsatzdaten in ein entsprechendes Format zu bringen für: Quicken, Starmoney, MoneyMonay, Subsembly Banking4W,...
# -*- coding: utf-8 -*-
import re
sentinel = ''
input = ''
regex = '(\d{2}\.\d{2}\.\d{4})\s(\d{2}\.\d{2}\.\d{4})\s(.+?)(?:\sVisa)?\s((?:\d*\.)?\d{1,3},\d{2})(-|\+?)\n'
# Lese Eingabe (Barclaycard PDF öffnen, strg+A, strg+c)
for line in iter(raw_input, sentinel):
input += line+'\n'
print input
# Export in MoneyMoney CSV Format
print 'Datum;Wertstellung;Kategorie;Name;Verwendungszweck;Konto;Bank;Betrag;Währung'
for m in re.finditer(regex, input):
print m.group(1)+';'+m.group(2)+';;;'+m.group(3)+';;;'+m.group(5)+m.group(4)+';;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment