Created
January 8, 2023 08:49
-
-
Save djmango/9a215ac69a4083ecbfcb4f2e3f4e01ac to your computer and use it in GitHub Desktop.
A script to convert a CSV account transaction file exported from Commerzbank to a format that can be imported into Simplifi.
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
""" A script to convert a CSV account transaction file exported from Commerzbank to a format that can be imported into Simplifi. """ | |
import csv | |
from datetime import datetime | |
from pathlib import Path | |
HERE = Path(__file__).parent | |
# EUR_TO_USD: float = 1.13 | |
EUR_TO_USD: float = 1.00 | |
writer = csv.writer(open(HERE/'converted.csv', 'w', newline='')) | |
writer.writerow(['Date', 'Payee', 'Amount']) | |
with open(HERE/'big.csv', 'r') as f: | |
reader = csv.reader(f, delimiter=';') | |
rows = list(reader)[1:] | |
for row in rows: | |
# 25.11.2021 to 11/25/2021 | |
date = datetime.strptime(row[0], '%d.%m.%Y').strftime('%m/%d/%Y') | |
payee = row[3] | |
amount = round(float(row[4].replace(',', '.')) * EUR_TO_USD, 2) | |
writer.writerow([date, payee, amount]) | |
print(f'{date} | {payee[:25]} | {amount}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment