Created
May 9, 2025 05:20
-
-
Save schnell18/f16b87f5efc57fde26b4f4da5caea705 to your computer and use it in GitHub Desktop.
Revisions
-
schnell18 created this gist
May 9, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,86 @@ #!/usr/bin/env python import re import sys HEADER = r""" \documentclass{article} \usepackage{booktabs,makecell,multirow,threeparttable,diagbox} \usepackage{caption} \usepackage[ colorlinks=true, linkcolor=blue, bookmarksnumbered=true, CJKbookmarks=true, bookmarksopen=true]{hyperref} \begin{document} \begin{table} \caption{AWS SAA Training Video Bookmarks}\label{tab:tspsaa} \begin{threeparttable} \begin{tabular*}{1.13\textwidth}{p{7em}cp{7em}cp{7em}c} \toprule \thead{\bfseries Topic} & \thead{\bfseries Time} & \thead{\bfseries Topic} & \thead{\bfseries Time} & \thead{\bfseries Topic} & \thead{\bfseries Time} \\ \midrule """ FOOTER = r""" \bottomrule\addlinespace[1ex] \end{tabular*} % \begin{tablenotes}\zihao{7} % \end{tablenotes} \end{threeparttable} \end{table} \end{document} """ if __name__ == "__main__": batch_size = 3 base_url = "https://www.youtube.com/watch?v=c3Cn4xYfxJY" topics = [] for seq, line in enumerate(sys.stdin): line = line.rstrip() time, title = line.split(" ", 1) m = re.match(r"(\d+):(\d+):(\d+)", time) if m: hour = int(m.group(1)) min = int(m.group(2)) sec = int(m.group(3)) t_secs = hour * 3600 + min * 60 + sec link = f"{base_url}\\&t={t_secs}" topics.append((title, time, link)) else: topics.append((time, title, None)) # print topics in table # print header print(HEADER) # print rows rows = len(topics) // batch_size remainder = len(topics) % batch_size for i in range(rows): for j in range(batch_size): tup = topics[i * batch_size + j] title, time, link = tup print(f"{title} & \\href{{{link}}}{{{time}}} ", end="") if j != batch_size - 1: print(" & ", end="") print(r"\\") if remainder != 0: for i in range(remainder): tup = topics[rows * batch_size + i] title, time, link = tup print(f"{title} & \\href{{{link}}}{{{time}}} ", end="") print(" & ", end="") for i in range(batch_size - remainder): print(" & ", end="") if i != batch_size - remainder - 1: print(" & ", end="") print(r"\\") print(FOOTER)