Skip to content
Snippets Groups Projects
Commit 7833c5d1 authored by Florian Ziemen's avatar Florian Ziemen
Browse files

extract summary from all lectures

parent 5eb63b3b
Branches summarizer
No related tags found
1 merge request!5extract summary from all lectures
#!/usr/bin/env python3
import glob
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
# But you can use your content.
def parse_file(filename):
logging.debug(f'opening {filename}')
with open(filename) as f:
lines = f.readlines()
titles = [ f"## {x[6:].strip()[1:-1]}\n" for x in lines if x.startswith("title:")]
entries = titles + [ f"##{x}" for x in lines if x[0] == "#" ]
entries = [ f'* {x[4:]}' if x[:4]=="####" else x for x in entries ]
return entries
files = glob.glob("[01]*/index.qmd")
all_entries = [ ]
for x in files:
all_entries.extend(parse_file(x))
with open("summary.md", "w") as outfile:
outfile.write("# Overview of all lectures\n")
outfile.writelines(all_entries)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment