Skip to content

Instantly share code, notes, and snippets.

@martin-martin
Created July 12, 2021 13:50
Show Gist options
  • Save martin-martin/6c9332e42a37f65ae3e814a94705f659 to your computer and use it in GitHub Desktop.
Save martin-martin/6c9332e42a37f65ae3e814a94705f659 to your computer and use it in GitHub Desktop.
Find and add lesson times mentioned in a Markdown document
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