import os def split_massive_file(input_file="words.txt", lines_per_file=200000): # Check if the giant file exists if not os.path.exists(input_file): print(f"āŒ Error: Could not find '{input_file}' in this folder.") return print(f"ā³ Reading massive file '{input_file}'...") # Read all lines with open(input_file, 'r', encoding='utf-8') as f: # Strip whitespace/newlines to clean it up while reading lines = [line.strip() for line in f if line.strip()] total_lines = len(lines) print(f"āœ… Loaded {total_lines:,} total words.") # Split and save into chunks for i in range(0, total_lines, lines_per_file): chunk = lines[i:i + lines_per_file] part_num = (i // lines_per_file) + 1 output_file = f"part{part_num}.txt" with open(output_file, 'w', encoding='utf-8') as out: out.write('\n'.join(chunk)) print(f"šŸ“¦ Created {output_file} ({len(chunk):,} words)") print("\nšŸŽ‰ All done! You can now upload these parts to the bot one by one.") if __name__ == "__main__": # You can change "words.txt" if your giant file is named something else # 200000 is the safe limit for a 256MB Redis database split_massive_file("words.txt", 200000)