Skip to content

Instantly share code, notes, and snippets.

@Debilski
Created August 5, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Debilski/40d02796875b23d7aef160895985ce67 to your computer and use it in GitHub Desktop.
Save Debilski/40d02796875b23d7aef160895985ce67 to your computer and use it in GitHub Desktop.
Convert pecunia csv to moneymoney
import pandas as pd
# This needs to be exported from Pecunia (in that order!)
names = [
'Datum', # Called 'Buchungsdatum' in Pecunia
'Wertstellung', # 'Valutadatum'
'Kategorien',
'Name', # 'Empfänger'
'Verwendungszweck',
'IBAN Empfänger',
'BIC Empfänger',
'Betrag', # 'Wert',
'Währung',
'Empfängerkonto',
'Bankleitzahl Empfängerbank'
]
transactions = pd.read_csv('Pecunia-export.csv', delimiter=';', names=names, index_col=False)
# We now take into account that some Pecunia transactions have an empty IBAN or BIC;
# in that case we default to the 'Empfängerkonto' and 'Bankleitzahl' respectively.
# MoneyMoney expects these as 'Konto' and 'Bank' so we create new columns.
transactions['Konto'] = transactions['IBAN Empfänger'].combine_first(pec['Empfängerkonto'])
transactions['Bank'] = transactions['BIC Empfänger'].combine_first(pec['Bankleitzahl Empfängerbank'])
# Export again:
transactions.to_csv('Pecunia-converted.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment