Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: remove_duplicate_lines.py
- # Author: Jeoi Reqi
- # This script removes duplicate lines from a text file, preserving unique lines in sorted order & saves to specified file.
- def remove_duplicates(input_file, output_file):
- unique_lines = set()
- with open(input_file, 'r') as infile:
- for line in infile:
- unique_lines.add(line)
- with open(output_file, 'w') as outfile:
- outfile.writelines(sorted(unique_lines))
- if __name__ == "__main__":
- input_file = "geolocations.txt" # Replace with the actual input file name
- output_file = "output_without_duplicates.txt" # Replace with the desired output file name
- remove_duplicates(input_file, output_file) # Remove the duplicates
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement