[Tutor] newbie text parsing question

S A buc40@bemail.org
Mon, 2 Sep 2002 07:54:00 -0700


Try re module.

You could use re to search and remove everything before the colon and the colon itself. You can then "slice" the spaces before the data and then save each piece of data to a comma seperated file. This file can easily be imported into a spreadsheet.

Good Luck.
SA

> Ron Nixon <nixonron@yahoo.com> tutor@python.org [Tutor] newbie text parsing questionDate: Wed, 28 Aug 2002 08:57:22 -0700 (PDT)
>
>
>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
><< msg2.html >>



"I can do everything on my Mac that I used to do on my PC, plus alot more ..."

-Me

------------------------------------------------------------
Free, BeOS-friendly email accounts: http://BeMail.org/
BeOS News and Community: http://www.BeGroovy.com/


---------------------------------------------------------------------
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
---------------------------------------------------------------------