import pandas as pd
from pathlib import Path

datev_path = 'C:/Projekte/Datev'
df_files = []

for filename in Path(datev_path).glob('*.csv'):
    df = pd.read_csv(filename, decimal=',', sep=';', encoding='latin-1', converters={i: str for i in range(0, 200)},
                     names=['fünf', 'KTR', 'Nummer', 'Modellname'])

    df['Marke'] = filename.name.split('_')[2]
    df_files.append(df)

df = pd.concat(df_files)
df['KTR_Nr'] = df['Nummer'].str.slice(-2)
df['Modell'] = df['KTR_Nr'] + ' - ' + df['Modellname']
df['Ebene1'] = 'Neuwagen'
df[['Ebene1', 'Marke', 'Modell']].to_csv(datev_path + '/output.txt', encoding='latin-1', sep=';', index=False)
