Explorar o código

'nnyverter.py' ändern

?!(StellPl.|StellPl)
tsi %!s(int64=5) %!d(string=hai) anos
pai
achega
560e974bdd
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  1. 4 4
      nnyverter.py

+ 4 - 4
nnyverter.py

@@ -30,7 +30,7 @@ def convert_pdf_to_txt(path):
     retstr.close()
     return text
 
-regex = r"^Tour Nr:\n\n(\d*)\n\nAbfahrt:.*?StellPl.Maut.*?^(\d*(,\d*)?|0)\sKM$"
+regex = r"^Tour Nr:\n\n(\d*)\n\nAbfahrt:.*?(?!(StellPl.|StellPl))\nMaut.*?^(\d*(,\d*)?|0)\sKM$"
 
 
 total = 0.0
@@ -56,9 +56,9 @@ with open("ergebnis.csv", 'w', newline='') as csvfile:
 
         for matchNum, match in enumerate(matches, start=1):
             ##print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
-            spamwriter.writerow([str("=\"" + match.group(1) + "\"")] + [str(match.group(2)).replace(",",",")])
-            print ("Tour " + str(i) + "," + str(match.group(1)) + "," + str(match.group(2)).replace(",","."))
-            daily = daily + float(match.group(2).replace(",","."))
+            spamwriter.writerow([str("=\"" + match.group(1) + "\"")] + [str(match.group(3)).replace(",",",")])
+            print ("Tour " + str(i) + "," + str(match.group(1)) + "," + str(match.group(3)).replace(",","."))
+            daily = daily + float(match.group(3).replace(",","."))
             i = i+1
         print(daily)
         total = total + daily