gpt-4.1-mini-2025-04-14· OpenAI
LMArena Human Preference 140K
Write me a script that - read from a file a row and check if this text is in the other…
- User
Write me a script that
- read from a file a row and check if this text is in the other file
- Assistant
Certainly! Here's a simple Python script that reads each line from one file and checks if that line (text) exists anywhere in another file.
def check_lines_in_file(source_file, target_file): # Read all lines from the target file into a set for fast lookup with open(target_file, 'r', encoding='utf-8') as f: target_lines = set(line.strip() for line in f) # Open the source file and check each line with open(source_file, 'r', encoding='utf-8') as f: for line in f: line = line.strip() if line in target_lines: print(f"Found: {line}") else: print(f"Not found: {line}") if __name__ == "__main__": source_file = "source.txt" # file with lines to check target_file = "target.txt" # file to check against check_lines_in_file(source_file, target_file)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.