I have an external file that I need to have into a dictionary. Each article begins with <NEW DOCUMENT>, and I am unaware of how I can pull all the information from the file, starting on the line below <newdoc> and ending before reaching the other <newdoc>. Here is what I have so far.
for line in file2:
line = line.strip()
line_list = line.split()
if "NEW DOCUMENT" in line:
doc_num+=1
new_dict[doc_num] = line
print(new_dict)
The file looks like this.
<NEW DOCUMENT>
Look on the bright
side of Life.
<NEW DOCUMENT>
look on the very, dark
side of the Moon
Here’s a modification to your solution: