I got Tuco'd!
- 103d 8h 7m
Thanks. There ended being a technical hurdle where the files had a mixed encoding of ascii and binary and the string that I wanted was in the ascii bits, so this result didn't help. I got access back and tried to engineer a request that would produce a working version but couldn't. Everything I generated would've either thrown an exception or failed in another way. No big deal though.View attachment 455035
import os import csv def search_files(directory, search_string, csv_file): with open(csv_file, 'w', newline='') as f: writer = csv.writer(f) writer.writerow(['File Path', 'String Value']) for root, dirs, files in os.walk(directory): for file in files: file_path = os.path.join(root, file) with open(file_path, 'r') as f: file_contents = f.read() if search_string in file_contents: writer.writerow([file_path, search_string]) search_files('/path/to/directory', 'search_string', 'output.csv')