|
@@ -30,28 +30,37 @@ def convert_pdf_to_txt(path):
|
|
|
retstr.close()
|
|
retstr.close()
|
|
|
return text
|
|
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.Maut.*?^(\d*(,\d*)?|0)\sKM$"
|
|
|
|
|
|
|
|
os.chdir("./")
|
|
os.chdir("./")
|
|
|
print("moin")
|
|
print("moin")
|
|
|
with open("ergebnis.csv", 'w', newline='') as csvfile:
|
|
with open("ergebnis.csv", 'w', newline='') as csvfile:
|
|
|
spamwriter = csv.writer(csvfile, delimiter=';',
|
|
spamwriter = csv.writer(csvfile, delimiter=';',
|
|
|
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
|
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
|
|
|
|
+
|
|
|
for file in glob.glob("*.pdf"):
|
|
for file in glob.glob("*.pdf"):
|
|
|
|
|
+ daily = 0.0
|
|
|
print("Beginne mit " + file + " alles guddes!")
|
|
print("Beginne mit " + file + " alles guddes!")
|
|
|
spamwriter.writerow([str(file)])
|
|
spamwriter.writerow([str(file)])
|
|
|
out = convert_pdf_to_txt(file)
|
|
out = convert_pdf_to_txt(file)
|
|
|
-
|
|
|
|
|
|
|
+ file = open("testfile.txt","w", encoding='utf-8')
|
|
|
|
|
+
|
|
|
|
|
+ file.write(out)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ file.close()
|
|
|
matches = re.finditer(regex, out, re.MULTILINE | re.DOTALL)
|
|
matches = re.finditer(regex, out, re.MULTILINE | re.DOTALL)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
i = 1
|
|
i = 1
|
|
|
|
|
|
|
|
for matchNum, match in enumerate(matches, start=1):
|
|
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()))
|
|
##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(",",".")])
|
|
|
|
|
|
|
+ spamwriter.writerow([str("=\"" + match.group(1) + "\"")] + [str(match.group(2)).replace(",",",")])
|
|
|
print ("Tour " + str(i) + "," + 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(",","."))
|
|
|
i = i+1
|
|
i = i+1
|
|
|
|
|
+ print(daily)
|
|
|
spamwriter.writerow([])
|
|
spamwriter.writerow([])
|
|
|
print("ok")
|
|
print("ok")
|