Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.0 kB
4
Indexable
Never
import random
import string
import os
from concurrent.futures import ThreadPoolExecutor

# Define characters and length
CHARS = string.ascii_letters + string.digits
LENGTH = 6
STRINGS_PER_FILE = 50000
NUM_THREADS = 8
OUTPUT_DIR = 'Vandar-str'

# Ensure output directory exists
os.makedirs(OUTPUT_DIR, exist_ok=True)

def generate_random_string(length):
    return ''.join(random.choices(CHARS, k=length))

def generate_and_write(file_index):
    filename = os.path.join(OUTPUT_DIR, f'filestrings_{file_index}.txt')
    with open(filename, 'w') as f:
        for _ in range(STRINGS_PER_FILE):
            f.write(generate_random_string(LENGTH) + '\n')

def main():
    total_strings = 500000  # Adjust this number as needed
    total_files = (total_strings + STRINGS_PER_FILE - 1) // STRINGS_PER_FILE

    with ThreadPoolExecutor(max_workers=NUM_THREADS) as executor:
        executor.map(generate_and_write, range(1, total_files + 1))

if __name__ == '__main__':
    main()
Leave a Comment