Last active
March 24, 2019 19:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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