I have a folder that is filled with text reports, the content of which should be stacked into a single list variable.
Each record/index of the list, ought to be the full content of each document.
So far I have this code, yet it isn't functioning too.
dir = os.path.join(current_working_directory, 'FolderName')
file_list = glob.glob(dir + '/*.txt')
corpus = [] #-->my list variable
for file_path in file_list:
text_file = open(file_path, 'r')
corpus.append(text_file.readlines())
text_file.close()
I need to whether is there any better way to do this?