Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- # goes through all text files in a directory
- # looks for lines starting with the target strings and put them all into one text file
- target_strings = ["Model:", "MaxCtx:", "ProcessingTime:", "ProcessingSpeed:", "GenerationTime:", "GenerationSpeed:", "TotalTime:"]
- matching_lines = []
- for filename in os.listdir("."):
- if filename.endswith(".txt"):
- # Open the file and read its contents
- with open(filename, "r") as f:
- lines = f.readlines()
- for line in lines:
- for target_string in target_strings:
- if line.lstrip().startswith(target_string):
- # If it matches, add it to our list of matching lines
- matching_lines.append(line.strip())
- with open("consolidated.txt", "w") as f:
- f.write("\n".join(matching_lines))
- print("Consolidated file written to consolidated.txt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement