gchr_error.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import pandas as pd
  2. base_dir = "/home/robert/projekte/python/gcstruct/Siebrecht/"
  3. def read_csv():
  4. header = ["Kontonummer", "Wert", "Fehler", "Beschreibung"]
  5. df_log = pd.read_csv(
  6. base_dir + "Siebrecht_12_2021.txt",
  7. decimal=",",
  8. sep="\t",
  9. encoding="latin-1",
  10. converters={0: str, 1: str, 2: str, 3: str},
  11. header=None,
  12. names=header,
  13. ) # , skiprows=3)
  14. df_log["Marke_HBV"] = df_log["Kontonummer"].str.slice(4, 8)
  15. df_log["Site"] = df_log["Kontonummer"].str.slice(8, 10)
  16. df_log["Account"] = df_log["Kontonummer"].str.slice(0, 4)
  17. df_log["Origin"] = df_log["Kontonummer"].str.slice(10, 12)
  18. df_log["SalesChannel"] = df_log["Kontonummer"].str.slice(12, 14)
  19. df_log["CostCarrier"] = df_log["Kontonummer"].str.slice(14, 16)
  20. # df_log['CumulatedYear'] = df_log['Wert'].str.replace(r'\.', '', regex=True)
  21. df_export = pd.read_csv(
  22. base_dir + "export_2021-12.csv", sep=";", encoding="latin-1", converters={i: str for i in range(0, 200)}
  23. )
  24. df = df_export.merge(
  25. df_log, how="left", on=["Marke_HBV", "Site", "Account", "Origin", "SalesChannel", "CostCarrier"]
  26. )
  27. df.to_csv(base_dir + "export_error_2021-12.csv", decimal=",", sep=";", encoding="latin-1", index=False)
  28. df_bookings = pd.read_csv(
  29. base_dir + "GuV_Bilanz_Salden_Debug.csv",
  30. decimal=",",
  31. sep=";",
  32. encoding="latin-1",
  33. converters={0: str, 1: str, 6: str, 7: str},
  34. )
  35. df = df.merge(df_bookings, how="inner", on=[])
  36. if __name__ == "__main__":
  37. read_csv()