title: How to parse exact data without including surrounding text?
body: <p>My code is very close to succeeding but I just need a little help. </p>
  
  <p>I have 100's of pages of data but I am working on parsing only 1 page perfectly before I apply it to the others. In this one page, which is an email, I need to extract several things: a Date, Sector, Fish Species, Pounds, and Money. So far I have been successful in using RegularExpressions to recognize certain words and extract the data from that line: such as looking for "Sent" because I know the Date information will always follow that, and looking for either "Pounds" or "lbs" because the Pounds information will always precede that.</p>
  
  <p>The problem I am having is that my code is grabbing the entire line that the data is on, not just the numeric data. I want to grab just the number value for Pounds, for example, but I realize this will be extremely difficult because every one of the 100's of emails is worded differently. I'm not sure if it is even possible to make this code foolproof because I need RegEx to recognize the text that surrounds the data, but not include it in my export command. So will I simply be blindly grabbing at characters following certain recognized words?</p>
  
  <p>Here is a piece of my code used for extracting the Pounds data:</p>
  
  <pre><code>for filename in os.listdir(path):
      file_path = os.path.join(path, filename)
      if os.path.isfile(file_path):
          with open(file_path, 'r') as f:
              sector_result = []
              pattern = re.compile("Pounds | lbs", re.IGNORECASE)
              for linenum, line in enumerate(f):
              if pattern.search(line) != None:
                  sector_result.append((linenum, line.rstrip('\n')))
                  for linenum, line in sector_result:
                      print ("Pounds:", line)
  </code></pre>
  
  <p>And here is what it prints out:</p>
  
  <pre><code>Pounds: -GOM Cod up to 5,000 lbs (live wt) @ 1.40 lbs
  Pounds: -GOM Cod up to 5,000 lbs (live wt) @ 1.40 lbs
  Pounds: -American Plaice 2,000 lbs      .60 lbs or best offer
  </code></pre>
  
  <p>Ideally I would just like the 5,000 lb numeric value to be exported but I am not sure how I would go about grabbing just that number. </p>
  
  <p>Here is the original email text I need to parse:</p>
  
  <pre><code>From: 
  Sent: Friday, November 15, 2013 2:43pm
  To: 
  
  Subject: NEFS 11 fish for lease
  
  Greetings,
  
  NEFS 11 has the following fish for lease:
  
  -GOM Cod up to 5,000 lbs (live wt) @ 1.40 lbs
  -American Plaice 2,000 lbs      .60 lbs or best offer
  </code></pre>
  
  <p>Here is another separate email though that will need to be parsed; this is why writing this code is difficult because it'll have to tackle a variety of differently worded emails, since all are written by different people: </p>
  
  <pre><code>From:
  Sent: Monday, December 09, 2013 1:13pm
  To:
  
  Subject: NEFS 6 Stocks for lease October 28 2013
  
  Hi All,
  
  The following is available from NEFS VI:
  
  4,000  lbs. GBE COD (live wt)
  
  10,000 lbs. SNE Winter Flounder
  
  10,000 lbs. SNE Yellowtail
  
  10,000 lbs GB Winter Flounder
  
  Will lease for cash or trade for GOM YT, GOM Cod, Dabs, Grey sole stocks on equitable basis.  
  
  Please forward all offers.
  
  Thank you,
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/XBb4U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XBb4U.png" alt="And here is another image of data that can be found in the emails...I can handle parsing the written txt in the body of emails, I can handle parsing the attached PDFs, but I am completely lost with how to handle these. So any ideas anyone has I&#39;m all ears"></a></p>
  
  <p>Any and all help is appreciated, as well as question asking criticism. Thanks. </p>