mirror of
https://github.com/soapingtime/diyhrt.git
synced 2026-09-05 04:20:20 +02:00
re-initialize and make some changes. repository got to around 2 gigabytes and needed to be more efficient
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
def remove_trailing_spaces(line):
|
||||
return line.rstrip()
|
||||
|
||||
def remove_duplicate_lines(file_path):
|
||||
lines_seen = set()
|
||||
output_lines = []
|
||||
|
||||
with open(file_path, 'r') as file:
|
||||
for line in file:
|
||||
cleaned_line = remove_trailing_spaces(line)
|
||||
|
||||
if cleaned_line.startswith("https://diyhrt.cafe") and cleaned_line not in lines_seen:
|
||||
lines_seen.add(cleaned_line)
|
||||
output_lines.append(line)
|
||||
|
||||
with open(file_path, 'w') as file:
|
||||
file.writelines(output_lines)
|
||||
|
||||
# Usage example
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Please provide the file path as an argument.")
|
||||
else:
|
||||
file_path = sys.argv[1]
|
||||
remove_duplicate_lines(file_path)
|
||||
Reference in New Issue
Block a user