Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def extract_free_lines(input_file, output_file):
- free_lines = []
- with open(input_file, 'r', encoding='utf-8') as f_in:
- for line in f_in:
- # Remove trailing whitespace and newlines
- line = line.rstrip()
- # Check if line ends with "(free)"
- if line.endswith("(free)"):
- free_lines.append(line)
- with open(output_file, 'w', encoding='utf-8') as f_out:
- for line in free_lines:
- f_out.write(line + '\n')
- # Replace these with your full paths
- input_path = 'C:\\path\\to\\your\\input.txt' # Windows example
- output_path = 'C:\\path\\to\\your\\output.txt'
- # For Linux/Mac, use format like:
- # input_path = '/path/to/your/input.txt'
- # output_path = '/path/to/your/output.txt'
- # Run the function with full paths
- extract_free_lines(input_path, output_path)
Advertisement
Add Comment
Please, Sign In to add comment