On 2008-11-21 16:18, Chuck Connors wrote:
> Hey guys.  I'm working on a little program to help my wife catalog her/
> our coupons.  I found a good resource but need help formatting the
> text data so that I can import it into a mysql database. Here's the
> data format:
> 
> 409220000003 Life Fitness Products $1 (12-13-08) (CVS)
> 546500181141 Oust Air Sanitizer, any B1G1F up to $3.49 (1-17-09) .35
> each
> 518000159258 Pillsbury Crescent Dinner Rolls, any .25 (2-14-09)
> 518000550406 Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini
> Cinnamon Rolls, etc. .40 (2-14-09)
> 
> The first value (large number) is the UPC, the next element is the
> coupon description, followed by a date in parenthesis.  Those are the
> only three elements I am concerned with.  Can someone help me in
> reformatting this:
> 
> 409220000003 Life Fitness Products $1 (12-13-08) (CVS)
> 546500181141 Oust Air Sanitizer, any B1G1F up to $3.49 (1-17-09) .35
> each
> 518000159258 Pillsbury Crescent Dinner Rolls, any .25 (2-14-09)
> 518000550406 Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini
> Cinnamon Rolls, etc. .40 (2-14-09)
> 
> into something like this:
> 
> "409220000003","Life Fitness Products $1","12-13-08"
> "546500181141","Oust Air Sanitizer, any B1G1F up to $3.49","1-17-09"
> "518000159258","Pillsbury Crescent Dinner Rolls, any .25","2-14-09"
> "518000550406","Pillsbury Frozen Grands Biscuits, Cinnamon Rolls, Mini
> Cinnamon Rolls, etc. .40","2-14-09"
> 
> Any help, pseudo code, or whatever push in the right direction would
> be most appreciated.  I am a novice Python programmer but I do have a
> good bit of PHP programming experience.

Have a look at the csv module:

http://www.python.org/doc/2.5.2/lib/module-csv.html

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 21 2008)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2008-11-12: Released mxODBC.Connect 0.9.3      http://python.egenix.com/

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to