[Tutor] newbie text parsing question

Ron Nixon nixonron@yahoo.com
Wed, 28 Aug 2002 08:57:22 -0700 (PDT)


--0-1024771816-1030550242=:8637
Content-Type: text/plain; charset=us-ascii


Ive got a file that looks like this:

   Case Number: 076-2000  Recall Notification Report:  RNR076-2000
   Date Opened: 12/20/2000  Date Closed:  04/20/2001
   Recall Class:  1  Press Release (Y/N):  Y
   Domestic Est. Number:  02040  M     Name:  Harper's Country Ham
   Imported Product (Y/N):  Y      Foreign Estab. Number:  N/A
   City:  Clinton   State:  KY  Country:  USA
   Product:  Country Ham
   Problem:  BACTERIA  Description: LISTERIA
   Total Pounds Recalled:  10,400  Pounds Recovered:    7,561

 

I'd like to be able to read all of the file in a extract the data following the Title and ":" to produce some like this:

076-2000, RNR076-2000,04/20/2001,04/20/2001,1,Y,02040  M, Harper's Country Ham, etc

that I can then import into a spreadsheet or database. I found nothing at the Python.org site nor in the Text Processing using Python book. Any ideas? thanks in advance

 

Ron



---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
--0-1024771816-1030550242=:8637
Content-Type: text/html; charset=us-ascii

<P>Ive got a file that looks like this:</P>
<P>&nbsp;&nbsp; Case Number: 076-2000&nbsp; Recall Notification Report:&nbsp; RNR076-2000<BR>&nbsp;&nbsp; Date Opened: 12/20/2000&nbsp; Date Closed:&nbsp; 04/20/2001<BR>&nbsp;&nbsp; Recall Class:&nbsp; 1&nbsp; Press Release (Y/N):&nbsp; Y<BR>&nbsp;&nbsp; Domestic Est. Number:&nbsp; 02040&nbsp; M&nbsp;&nbsp;&nbsp;&nbsp; Name:&nbsp; Harper's Country Ham<BR>&nbsp;&nbsp; Imported Product (Y/N):&nbsp; Y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Foreign Estab. Number:&nbsp; N/A<BR>&nbsp;&nbsp; City:&nbsp; Clinton&nbsp;&nbsp; State:&nbsp; KY&nbsp; Country:&nbsp; USA<BR>&nbsp;&nbsp; Product:&nbsp; Country Ham<BR>&nbsp;&nbsp; Problem:&nbsp; BACTERIA&nbsp; Description: LISTERIA<BR>&nbsp;&nbsp; Total Pounds Recalled:&nbsp; 10,400&nbsp; Pounds Recovered:&nbsp;&nbsp;&nbsp; 7,561</P>
<P>&nbsp;</P>
<P>I'd like to be able to read all of the file in a extract the data following the Title and ":" to produce some like this:</P>
<P>076-2000, RNR076-2000,04/20/2001,04/20/2001,1,Y,02040&nbsp; M, Harper's Country Ham, etc</P>
<P>that I can then import into a spreadsheet or database. I found nothing at the Python.org site nor in the Text Processing using Python&nbsp;book. Any ideas? thanks in advance</P>
<P>&nbsp;</P>
<P>Ron</P><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/finance/mailsig/new/*http://finance.yahoo.com">Yahoo! Finance</a> - Get real-time stock quotes
--0-1024771816-1030550242=:8637--