I used BeautifulSoup to parse a website and store the content. It is in this form:
records = [[[<p>data_1_1</p>], [<p>data_1_2</p>],[], [<li>data_1_3</li>]],
[[<p>data_2_1</p>], [<p>data_2_2</p>], [], [<li>data_2_3</li>]]]
I am having trouble making this:
records = [["data_1_1", "data_1_2", "data_1_3"],
["data_2_1", "data_2_2", "data_2_3"]]
I tried list comprehensions:
text_records = [sum(record, []) for record in records]
but the text is still wrapped in <p> or <li> tags.
text_records = [item.string for item in sum(record, []) for record in records]
takes the text out of tags, but this gives one large list, with the same values repeated multiple times.
I know there is plenty out there on list comprehensions in python, and I've searched SO, but I can't find anything to help with this situation.