Created
July 12, 2021 13:50
-
-
Save martin-martin/6c9332e42a37f65ae3e814a94705f659 to your computer and use it in GitHub Desktop.
Find and add lesson times mentioned in a Markdown document
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
from pathlib import Path | |
import re | |
with open('outline.md', 'r') as f_in: | |
content = f_in.read() | |
# Finds all time mentions in the format shown below | |
pattern = r'\((\d+)\smin\)' # (3 min) | |
minutes = re.findall(pattern, content) | |
# print([int(m) for m in minutes]) | |
total_time = sum([int(m) for m in minutes]) | |
print(total_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment