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 = ['', """ """, '', '', f'Total lines written: {return_count}', '
', f'Total lines per hour: {lines_per_hour}', '
', f'Total hours: {hour_count}', '
', '
', ] 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'') html_content.append("") with open("graphs.html", "w") as f: f.write("\n".join(html_content)) print("graphs.html generated!")