I use the following code segment to read a file in python:
with open (\"data.txt\", \"r\") as myfile: data=myfile.readlines()
Input fil
Regular expression works too:
import re with open("depression.txt") as f: l = re.split(' ', re.sub('\n',' ', f.read()))[:-1] print (l)
['I', 'feel', 'empty', 'and', 'dead', 'inside']