Splitting the elements of a list into a list and then splitting them again
<p>This is a sample of the raw text i'm reading:</p>

<pre><code>ID: 00000001
SENT: to do something
to    01573831
do    02017283
something    03517283

ID: 00000002
SENT: just an example
just    06482823
an    01298744
example    01724894
</code></pre>

<p>Right now I'm trying to split it into a lists of lists of lists.</p>

<p>Topmost level list: By the ID so 2 elements here (done)</p>

<p>Next level: Within each ID, split by newlines</p>

<p>Last level: Within each line split the word and ID, for the lines beginning with ID or SENT, it doesn't matter if they are split or not. Between the word and their ID is an indent (\t)</p>

<p>Current code:</p>

<pre><code>f=open("text.txt","r")
raw=list(f)
text=" ".join(raw)
wordlist=text.split("\n \n ") #split by ID
toplist=wordlist[:2] #just take 2 IDs
</code></pre>

<p>Edit:
I was going to cross-reference the words to another text file to add their word classes which is why i asked for a lists of lists of lists. </p>

<p>Steps:</p>

<p>1) Use .append() to add on word classes for each word</p>

<p>2) Use "\t".join() to connect a line together</p>

<p>3) Use "\n".join() to connect different lines in an ID</p>

<p>4) "\n\n".join() to connect all the IDs together into a string</p>

<p>Output:</p>

<pre><code>ID: 00000001
SENT: to do something
to    01573831    prep
do    02017283    verb
something    03517283    noun

ID: 00000002
SENT: just an example
just    06482823    adverb
an    01298744    ind-art
example    01724894    noun
</code></pre>
