I'm working with a file that has times and values on the next line after the times. I can extract the times into a list but need to get the value of the line following also. This would be a list of time/value pairs.
file looks like this:
10:30 AM
F
10:40 AM
10:50 AM
F
11:00 AM
1
11:10 AM
11:20 AM
1
11:30 AM
1
11:40 AM
1
11:50 AM
1
12:00 PM
12:10 PM
1
12:20 PM
1
12:30 PM
1
12:40 PM
1
12:50 PM
1
The code i'm using to get the times is this:
get_source = driver.page_source
soup = BeautifulSoup(get_source, 'html.parser')
time_pattern = re.compile(r'\s(\d{1,2}\:\d{2}\s?(?:AM|PM|am|pm))')
times = time_pattern.findall(soup.get_text())
Where
times = ['10:30 AM', '10:40 AM', '10:50 AM', '11:00 AM'........]
I want to also get the value of the next line (blank, F, or 1) creating a time/value pair.
timesvaluepair = [[10:30 AM, 'F'],[10:40 AM, ''],[10:50 AM, 'F'],[11:00 AM, '1'],.........]
How would you do this?