Skip to content

Instantly share code, notes, and snippets.

@seandlg
Last active March 24, 2019 19:39
Show Gist options
  • Save seandlg/879458c48ff3dbac0b9ba769b00d0bb4 to your computer and use it in GitHub Desktop.
Save seandlg/879458c48ff3dbac0b9ba769b00d0bb4 to your computer and use it in GitHub Desktop.
Script to modify .csv Credit Card Transactions of DKB for use with GNUCash
import re, sys, os
if __name__ == '__main__':
filePath = os.path.abspath(sys.argv[1])
print("Reading %s"%str(filePath))
with open(filePath, 'r', errors='ignore') as f:
data = f.read()
print(data)
with open(filePath, 'w') as f:
searchString = r'(\d{2})\.(\d{2})\.(\d{4})'
replaceString = r'\g<3>-\g<2>-\g<1>'
data = re.sub(searchString, replaceString, data)
searchString = r','
replaceString = r'.'
data = re.sub(searchString, replaceString, data)
f.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment