File size: 1,299 Bytes
eb6a7c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)