I was given a long .txt file that when read returns one long string that is a large corpus of words that are separated by \n as shown:
\na+\nabound\nabounds\nabundance\nabundant\naccessable\naccessible\nacclaim\nacclaimed\nacclamation\naccolade\naccolades\naccommodative\naccomodative\naccomplish\naccomplished\naccomplishment...\nworld-famous\nworth\nworth-while\nworthiness\nworthwhile\nworthy\nwow\nwowed\nwowing\nwows\nyay\nyouthful\nzeal\nzenith\nzest\nzippy\n
I need to split this string into a list of these words but none of the commands I usually use for .csv files is working. I have tried stripping, replacing(), split(), splitline() and nothing will break this into a list of these words. I would be grateful for any assistance.
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '[',']','@']
punctuation_chars2=["'", '"', ",", ".", "!",":",";",'#','[',']','@','\n']
# list of positive words to use
positive_words = []
wrd_list = []
new_list = []
with open("positive_words.txt", 'r', encoding="utf-16") as pos_f:
for lin in pos_f:
if lin[0] != ';' and lin[0] != '\n':
positive_words.append(lin.strip())
pos_wrds = positive_words[0]
pos_wrds.strip()
print(pos_wrds)
for p in punctuation_chars:
pos_wrds = pos_wrds.replace(p,"")
print(pos_wrds)
wrd_list = pos_wrds.splitlines()
new_list = wrd_list[-1].splitlines
I would like to see a python list with each word separated: list = [a+, abound, abounds, abundance, abundant...]