I am new to Python, and have never tried Multithreading. My objective is to read set of file and get some specific data from the file. I have already created a code which is doing my task perfectly. But it is taking a lot of time as few files are very large.
final_output = []
for file in os.listdir(file_path):
final_string = error_collector(file_path, file)
final_output = final_output + final_string
The error_collector function is reading each line of the file and fetching useful information and returning a list for each file, which I am concatenating with the file list so that I can get all information in a single list.
What I want to achieve is some way by which I can do parallel processing of the files instead of reading one file at a time.
Can someone please help.
final_output = [error_collector(file_path, file) for file in os.listdir(file_path)]