title: Read data from text format into Python Pandas dataframe
body: <p>I am running Python 2.7 on Windows.</p>
  
  <p>I have a large text file (2 GB) that refers to 500K+ emails. The file has no explicit file type and is in the format:</p>
  
  <pre><code>email_message#: 1
  email_message_sent: 10/10/1991 02:31:01
  From: tomf@abc.com| Tom Foo |abc company|
  To: adee@abc.com| Alex Dee |abc company|
  To: benfor12@xyz.com| Ben For |xyz company|
  email_message#: 2
  email_message_sent: 10/12/1991 01:28:12
  From: timt@abc.com| Tim Tee |abc company|
  To: tomf@abc.com| Tom Foo |abc company|
  To: adee@abc.com| Alex Dee |abc company|
  To: benfor12@xyz.com| Ben For|xyz company|
  email_message#: 3
  email_message_sent: 10/13/1991 12:01:16
  From: benfor12@xyz.com| Ben For |xyz company|
  To: tomfoo@abc.com| Tom Foo |abc company|
  To: t212@123.com| Tatiana Xocarsky |numbers firm |
  ...
  </code></pre>
  
  <p>As you can see, each email has the following data associated with it:</p>
  
  <p>1) the time it was sent</p>
  
  <p>2) the email address who sent it</p>
  
  <p>3) the name of the person who sent it</p>
  
  <p>4) the company that person works for </p>
  
  <p>5) every email address that received the email</p>
  
  <p>6) the name of every person who received the email</p>
  
  <p>7) the company of every person who received the email</p>
  
  <p>In the text files there are 500K+ emails, and emails can have up to 16K recipients. There is no pattern in the emails in how they refer to names of people or the company they work at. </p>
  
  <p>I would like to take this large file and manipulate it in <code>python</code> so that it ends up as a <code>Pandas</code> <code>Dataframe</code>. I would like the <code>pandas</code> <code>dataframe</code> in the format like the screenshot from <code>excel</code> below:</p>
  
  <p><a href="https://i.stack.imgur.com/C1a69.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C1a69.png" alt="Sample Data Structure"></a></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My plan to solve this is to write a "parser" that takes this text file and reads in each line, assigning the text in each line to a particular columns of a <code>pandas</code> <code>dataframe</code>.</p>
  
  <p>I plan to write something like the below. Can someone confirm that this is the correct way to go about executing this? I want to make sure I am not missing a built-in <code>pandas</code> function or function from a different <code>module</code>. </p>
  
  <pre><code>#connect to object 
  data = open('.../Emails', 'r')
  
  #build empty dataframe
  import pandas as pd
  df = pd.DataFrame()
  
  #function to read lines of the object and put pieces of text into the
  # correct column of the dataframe
  for line in data:
       n = data.readline()
      if n.startswith("email_message#:"):
          #put a slice of the text into a dataframe
      elif n.startswith("email_message_sent:"):
          #put a slice of the text into a dataframe
      elif n.startswith("From:"):
          #put slices of the text into a dataframe
      elif n.startswith("To:"):
          #put slices of the text into a dataframe
  </code></pre>