import pandas as pd
import numpy as np
from pathlib import Path

export_dir = 'C:\\Users\\GAPS\\Dropbox\\Jugendchor 2000\\Kasse\\2020\\Export'


def import_csv(filename):
    kto = filename.name.split('_')[0]
    print(kto)
    df = pd.read_csv(filename, sep=';', decimal=',', encoding='utf-8', index_col=['IBAN', 'Laufende Nummer'], )
    df['Einnahmen'] = np.where(df['Betrag'] > 0, df['Betrag'], 0)
    df['Ausgaben'] = np.where(df['Betrag'] < 0, df['Betrag'], 0)
    print(df.shape)
    return df


df = [import_csv(f) for f in Path(export_dir).glob('*.csv')]
df_union = pd.concat(df)
print(df_union.shape)
