import pathlib all_content = [] 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 = ['', """ """, ''] 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!")