tsi 5 年 前
コミット
7a71707225
1 ファイル変更8 行追加7 行削除
  1. 8 7
      nnyverter.py

+ 8 - 7
nnyverter.py

@@ -32,6 +32,8 @@ def convert_pdf_to_txt(path):
 
 regex = r"^Tour Nr:\n\n(\d*)\n\nAbfahrt:.*?StellPl.Maut.*?^(\d*(,\d*)?|0)\sKM$"
 
+
+total = 0.0
 os.chdir("./")
 print("moin")
 with open("ergebnis.csv", 'w', newline='') as csvfile:
@@ -43,12 +45,9 @@ with open("ergebnis.csv", 'w', newline='') as csvfile:
         print("Beginne mit " + file + " alles guddes!")
         spamwriter.writerow([str(file)])
         out = convert_pdf_to_txt(file)
-        file = open("testfile.txt","w",  encoding='utf-8') 
-     
-        file.write(out) 
-        
-         
-        file.close() 
+        #file = open("testfile.txt","w",  encoding='utf-8') 
+        #file.write(out)
+        #file.close() 
         matches = re.finditer(regex, out, re.MULTILINE | re.DOTALL)
 
         
@@ -62,6 +61,8 @@ with open("ergebnis.csv", 'w', newline='') as csvfile:
             daily = daily + float(match.group(2).replace(",","."))
             i = i+1
         print(daily)
-        spamwriter.writerow(["Gesamt"] + [str("=\"" + str(round(daily, 2)) + "\"")])
+        total = total + daily
+        spamwriter.writerow(["Gesamt (Tag)"] + [str("=\"" + str(round(daily, 2)) + "\"")])
         spamwriter.writerow([])
         print("ok")
+    spamwriter.writerow(["Gesamt (Monat)"] + [str("=\"" + str(round(total, 2)) + "\"")])