Created
April 22, 2020 10:35
-
-
Save vklachkov/c9f6dc3a7b10ae4787d8027cc8dea4e4 to your computer and use it in GitHub Desktop.
Calculates the amount of money spent on taxis from a message backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
money = 0 | |
with open("raw.txt", encoding="utf-8") as f: | |
for line in f.readlines(): | |
if "YANDEX.TAXI" not in line: | |
continue | |
data = line.strip() | |
res = re.search(r"Покупка (\d*)[р]", data) | |
if res == None: | |
continue | |
money_raw = res.group(1) | |
if money_raw == None: | |
continue | |
money += int(money_raw) | |
print(money_raw) | |
print('-' * 80) | |
print(money) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment