datev_skr51_modelle.py 677 B

123456789101112131415161718
  1. import pandas as pd
  2. from pathlib import Path
  3. datev_path = 'C:/Projekte/Datev'
  4. df_files = []
  5. for filename in Path(datev_path).glob('*.csv'):
  6. df = pd.read_csv(filename, decimal=',', sep=';', encoding='latin-1', converters={i: str for i in range(0, 200)},
  7. names=['fünf', 'KTR', 'Nummer', 'Modellname'])
  8. df['Marke'] = filename.name.split('_')[2]
  9. df_files.append(df)
  10. df = pd.concat(df_files)
  11. df['KTR_Nr'] = df['Nummer'].str.slice(-2)
  12. df['Modell'] = df['KTR_Nr'] + ' - ' + df['Modellname']
  13. df['Ebene1'] = 'Neuwagen'
  14. df[['Ebene1', 'Marke', 'Modell']].to_csv(datev_path + '/output.txt', encoding='latin-1', sep=';', index=False)