Skip to content

Instantly share code, notes, and snippets.

@vklachkov
Created April 22, 2020 10:35
Show Gist options
  • Save vklachkov/c9f6dc3a7b10ae4787d8027cc8dea4e4 to your computer and use it in GitHub Desktop.
Save vklachkov/c9f6dc3a7b10ae4787d8027cc8dea4e4 to your computer and use it in GitHub Desktop.
Calculates the amount of money spent on taxis from a message backup
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