python - I need help making a list -
i trying make disorganized text file list suitable use python program. text file list of data seperated few spaces not in standard columns or organized. goal of program read through file using python , after each piece of data want there space, want make new line. output should list of data each term on 1 line. in addition there terms not want. terms want start "jj".
here have far. note not run yet. looking finishing program select terms starting jj , make new line @ space after jj term. robert
datafile = open ('c:\\textfile.txt', 'r') line_list = line.split(" ") x in line_list: if x.startswith("jj") : print line_list
edit: want open file called textfile , have python keep lines of data start "jj". additionaly want each data on it's own line, why want seperate them using space after each ilne of data? clearer?
lines = [item item in open('c:\textfile.txt', 'r').read().split(' ') if item.startswith("jj")]
Comments
Post a Comment