import argparse
import tempfile
import os

def remove_duplicate_rows(file_path):
    seen = set()
    temp_file_path = file_path + '.temp'
    total_lines = 0
    unique_lines = 0

    with open(file_path, 'r') as input_file, open(temp_file_path, 'w') as output_file:
        for line in input_file:
            total_lines += 1
            stripped_line = line.strip()
            if stripped_line not in seen:
                seen.add(stripped_line)
                output_file.write(line)
                unique_lines += 1

    os.replace(temp_file_path, file_path)
    
    duplicate_lines = total_lines - unique_lines
    reduction_percentage = (duplicate_lines / total_lines) * 100 if total_lines > 0 else 0

    print(f"\nStatistics for {file_path}:")
    print(f"Total lines processed: {total_lines}")
    print(f"Unique lines: {unique_lines}")
    print(f"Duplicate lines removed: {duplicate_lines}")
    print(f"Reduction: {reduction_percentage:.2f}%")

def main():
    parser = argparse.ArgumentParser(description="Remove duplicate rows from a text file.")
    parser.add_argument("file_path", help="Path to the text file to process")
    args = parser.parse_args()
    remove_duplicate_rows(args.file_path)

if __name__ == "__main__":
    main()