import re, os
from multiprocessing import Pool
directory = r'F:\data\\' #['a.txt', 'b.txt', 'c.txt', 'd.txt', 'e.txt']
raw_files = os.listdir(directory)
# TARGET FUNCTION
def print_result(raw_files):
for raw_file in raw_files:
with open(directory+raw_file, 'r', encoding = 'utf-16') as f: #FileNotFoundError: [Errno 2] No such file or directory: 'F:\\corpus_duplicated\\\\2'
raw = f.read()
if re.search('target', raw):
print(raw)
if __name__ == '__main__':
print(raw_files[:3]) #['a.txt', 'b.txt', 'c.txt']
pool = Pool(processes = 4)
pool.map(print_result, raw_files)
pool.close()
pool.join()
I want to directory+raw_file be F:\data\a.txt
but it results in F:\data\2 that can be seen in Error msg.
I think I didn't understand about multiprocessing yet, but I cannot know why via searching.
Thank you for help. (Attatched code is reduced one.)