I'm trying to ensure that an expected list of substrings occur in a list of strings. I need to know if one is missing so I can populate it. I need to find the indices of a list of substrings in a list of strings so I can pull the values of the string next to it. (Using Python 3.)
# List of strings parsed from a document
strings = [['name', 'Joe Sixpack', 'email', 'beerme@thebrew.com'],
['name', 'Winnie Cooler', 'email', 'Winnie Cooler', 'phone',
'555-555-5550']]
# Expected/desired headings
subs = ['name', 'email', 'phone']
Then check if all 'subs' are captured. If not, find which ones and fill them in with nan.
Expected Results:
{'name': 'Joe Sixpack', 'email': 'beerme@thebrew.com', 'phone': nan}
{'name': 'Winnie Cooler', 'email': 'Winnie Cooler', 'phone': '555-555-
5550'}