def remove_duplicates(input_file, output_file): | |
with open(input_file, 'r') as file: | |
lines = file.readlines() | |
unique_lines = set() | |
with open(output_file, 'w') as file: | |
for line in lines: | |
if line not in unique_lines: | |
file.write(line) | |
unique_lines.add(line) | |
if __name__ == "__main__": | |
import sys | |
if len(sys.argv) != 2: | |
print("Usage: python remove_duplicates.py <input_file>") | |
sys.exit(1) | |
input_file = sys.argv[1] | |
output_file = 'output_no_duplicates.txt' | |
remove_duplicates(input_file, output_file) |