Untitled
unknown
plain_text
2 years ago
902 B
10
Indexable
try:
# Open the input and output files
with open(input_file, 'r') as input_file, open(output_file, 'w') as output_file:
# Loop through each line in the input file
for line in input_file:
# Check if any of the important words appear in the line
if any(word in line.lower() for word in important_words):
# If yes, write the line to the output file
output_file.write(line)
# Set permissions on the output file
os.chmod(output_file.name, 0o777)
# Compress the output file and remove the uncompressed file
with open(output_file.name, 'rb') as input_file, gzip.open(output_file.name + '.gz', 'wb') as output_file_gz:
input_data = input_file.read()
output_file_gz.write(input_data)
Editor is loading...