I am trying to extract information out of a text file and store each "paragraph", by paragraph I mean I need the date (always the first index) and whatever description is associated with that date (the information right after that date, but before the next date), .txt looks likes
September 2013. **I NEED THE DATA THAT WOULD BE WRITTEN HERE STORED WITH ITS DATE HOWEVER
WHEN ANOTHER DATE SHOWS UP IT NEEDS TO BE SEPERATED
September 2013. blah blah balh this is an example blah blaha blah I need the information hereblah blah balh this is an example blah blaha blah I need the information here
blah blah balh this is an example blah blaha blah I need the information here
August 2013. blah blah balh this is an example blah blaha blah I need the information here
August 2013.blah blah balh this is an example blah blaha blah I need the information here
blah blah balh this is an example blah blaha blah I need the information hereblah blah balh this is an example blah blaha blah I need the information hereblah blah balh this is an example blah blaha blah I need the information here
June 2013. blah blah balh this is an example blah blaha blah I need the information hereeeeee
There isn't a definite number of lines which comes after the date.
I am able to find every line starting with a date using
with open("test.txt", encoding="utf8") as input:
for line in input:
for month in months:
if month in line:
print(line)
but this outputs
"May 2014. only the first line is taken in and not the rest of the paragraph
April 2013. only the first line is taken in and not the rest of the paragraph
December 2013. only the first line is taken in and not the rest of the paragraph
November 2012. only the first line is taken in and not the rest of the paragraph