pandas Read undelimited text file to dataframe
<p>I am very new to pandas. Up until now I've been learning pandas using csv files and excel spreadsheets.</p>

<p>Now I am faced with converting a text file to a dataframe. The text files is what I call sequential data. The format of the file is:</p>

<pre><code>State Name
City Name
State Name
City Name
City Name
City Name
...
</code></pre>

<p>All 50 states plus US territories are listed but the number of cities varies. I need to convert this into a dataframe like</p>

<pre><code>[[State Name, City Name1],[State Name, City Name2],...]
</code></pre>

<p>Using pandas read_table() method, I've been able to at least read the file into a dataframe, but now I'm not certain how to get it into the correct State Name City Name format.</p>

<p>I also have a dictionary of State Name/State 2 letter abbreviations available. The format of the dictionary is</p>

<pre><code>{'OH':'OHIO', 'KY':'Kentucky',...}
</code></pre>

<p>Is there a way I can use this dictionary, loop over the file and separate the state and city? or is there an easier way to accomplish this?</p>

<p>Thank you</p>

<p><strong>EDIT - Sample of Text File</strong>
A sample of the text file is listed below. Also, please not that I am unable to alter the file.</p>

<pre><code>Alabama[edit]  
Auburn (Auburn University)[1]
Florence (University of North Alabama) 
Jacksonville (Jacksonville State University)[2]
Livingston (University of West Alabama)[2] 
Montevallo (University of Montevallo)[2] 
Troy (Troy University)[2] 
Tuscaloosa (University of Alabama, Stillman College, Shelton State)[3][4] 

Tuskegee (Tuskegee University)[5] 
Alaska[edit] 
Fairbanks (University of Alaska Fairbanks)[2] 
Arizona[edit] 
Flagstaff (Northern Arizona University)[6] 
Tempe (Arizona State University) 
Tucson (University of Arizona)
</code></pre>