import pathlib all_content = [] return_count = 0 hour_count = 0 for file in pathlib.Path("logs_plain").glob("*.txt"): with open(file, "r") as f: return_count += f.read().count("[ENTER]") hour_count += 1 lines_per_hour = return_count // hour_count for file in pathlib.Path("logs_summaries").glob("*.txt"): with open(file, "r") as f: all_content.append(f.read()) with open("logs_summaries/merged.txt", "w") as f: f.write("\n\n".join(all_content)) html_content = ['<html>', """ <style> body { width:100%; background-color: #000; color: #fff; } img { width:40%; padding: 4%; float:left; } </style> """, '<body>', '<b>', f'Total lines written: {return_count}', '<br />', f'Total lines per hour: {lines_per_hour}', '</b>', '<br>', ] graph_images = list(pathlib.Path(".").glob("*.png")) graph_images.sort(key=lambda graph: graph.name) for graph_image in graph_images: html_content.append(f'<img src="{graph_image}"></img>') html_content.append("</body></html>") with open("graphs.html", "w") as f: f.write("\n".join(html_content)) print("graphs.html generated!")