Python 3 | Converting complex list data into groupings within a list?
<p>I am scraping data from my own facebook profile and have become stuck whilst trying to insert data into a sqlite3 database.</p>

<p>I have scraped my friends list and organized the result into a python  list  but the python list is messy to say the least. </p>

<p>I'll show you what I mean:</p>

<pre><code>['Jody Ann Elizabeth Lill\n98 mutual friends\nFriends\nGeorgia Gee Smith\n60 mutual friends\nFriends\nShannon Kirk\n52 mutual friends\nFriends\nNatasha Byars-Marsden\n4 mutual friends\nFriends\nLorrae Moakes\n36 mutual friends\nFriends\nAdam AP Kirk\n98 mutual friends\n7 new posts\nFriends\nLittle Mark Jr.\n5 mutual friends\nFriends\nMark Duffy\nFriends with Nat Hodgson\nFriends\nEdward McConville\n40 mutual friends\n3 new posts\nFriends', 'Tanisha Barlow\n2 mutual friends\n10 new posts\nFriends\nCatherine Firth\n4 mutual friends\nFriends\nJayde Woods\n56 mutual friends\n4 new posts\nFriends\nScott Goodall\n43 mutual friends\n4 new posts\nFriends\nNikki Harris\n43 mutual friends\n4 new posts\nFriends\nDebbie Goodall\n85 mutual friends\n6 new posts\nFriends\nConrick Junior\n48 mutual friends\n1 new post\nFriends\nBoris Bighead\n5 mutual friends\nFriends']
</code></pre>

<p>There are only two items in the above list! But I need them organised into the correct groups, so I would need:</p>

<pre><code>['Jody Ann Elizabeth Lill\n98 mutual friends\nFriends\n', 'Georgia Gee Smith\n60 mutual friends\nFriends\n', 'Shannon Kirk\n52 mutual friends\nFriends\n', 'Natasha Byars-Marsden\n4 mutual friends\nFriends\n', 'Lorrae Moakes\n36 mutual friends\nFriends\n', 'Adam AP Kirk\n98 mutual friends\n7 new posts\nFriends\n', 'Little Mark Jr.\n5 mutual friends\nFriends\n', 'Mark Duffy\nFriends with Nat Hodgson\nFriends\n', 'Edward McConville\n40 mutual friends\n3 new posts\nFriends', 'Tanisha Barlow\n2 mutual friends\n10 new posts\nFriends\n', 'Catherine Firth\n4 mutual friends\nFriends\n', 'Jayde Woods\n56 mutual friends\n4 new posts\nFriends\n', 'Scott Goodall\n43 mutual friends\n4 new posts\nFriends\n', 'Nikki Harris\n43 mutual friends\n4 new posts\nFriends\n', 'Debbie Goodall\n85 mutual friends\n6 new posts\nFriends\n', 'Conrick Junior\n48 mutual friends\n1 new post\nFriends\n', 'Boris Bighead\n5 mutual friends\nFriends']
</code></pre>

<p>As you can see each grouping doesn't have an equal number of items:</p>

<p>(This has 3 items in its group)</p>

<pre><code>'Jody Ann Elizabeth Lill\n98 mutual friends\nFriends\n',
</code></pre>

<p>vs.</p>

<p>(Whereas this has 4 items in its group)</p>

<pre><code>'Conrick Junior\n48 mutual friends\n1 new post\nFriends\n', 
</code></pre>

<p>I did think of creating a list of tuples but due the uneven number of items within the groups I thought that is sure to fail. </p>

<p>To give you an idea of what I actually want as a final outcome;</p>

<p>I need my list organised like so:</p>

<pre><code>[ ('Jody Ann Elizabeth Lill', '98 mutual friends', 'Friends'),
'Georgia Gee Smith', '60 mutual friends', 'Friends',
'Conrick Junior', '48 mutual friends', '1 new post,' 'Friends', 
'Shannon Kirk', '52 mutual friends', 'Friends' ]
</code></pre>

<p>Then I wish to iterate over them and insert them into a databse table like so:</p>

<pre><code>+---------------------------------+-----------------+--------------------------+------------------------+---------+
|        name                          | new_posts | mutual_friends    | already_friends |id         |
+---------------------------------+-----------------+--------------------------+------------------------+---------+
|Jody Ann Elizabeth Lill |                       |98 mutual friends| Friends                 |1          |
+---------------------------------+-----------------+--------------------------+------------------------+---------+
|Georgia Gee Smith        |                       |60 mutual friends | Friends                 |2          |
+---------------------------------+-----------------+--------------------------+------------------------+---------+
|Adam AP Kirk                  |7 new posts|98 mutual friends | Friends                |3          |
+---------------------------------+-----------------+--------------------------+------------------------+---------+
</code></pre>

<p>How can I convert my list so that I can then proceed to use that organised list into a database?</p>