File size: 523 Bytes
45ca953
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
import random
path = 'sis-novel1/files'
files = os.listdir(path)
random.shuffle(files)
files = files[:1000 ]
#merge files to one txt
with open('sel.txt', 'w', encoding='utf-8') as f:
    for i,file in enumerate(files):
        print(i,len(files))
        with open(path + '/' + file, 'r', encoding='utf-8') as f1:
            text=f1.read()
            text=text.replace('\n\n','[dooubleenter]')
            text=text.replace('\n','')
            text=text.replace('[dooubleenter]','\n')
            f.write(text)