file_list = glob.glob(os.path.join(os.getcwd(), "Directory", "*.txt"))
corpus = []
for file_path in file_list:
with open(file_path,'r') as stop_words:
stop_words.append(stop_words.read())
stopWords = stop_words.read().lower()
stopWordList = stopWords.split('\n')
stopWordList[-1:] = []
AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘append’
Thanks
>Solution :
Here is one way to get all words into a list.
file_list = glob.glob(os.path.join(os.getcwd(), "Directory", "*.txt"))
stopwords = []
for file_path in file_list:
with open(file_path, 'r') as f:
stopwords.extend(f.read().lower().splitlines())