Re: Need help converting text to csv format

2008-11-23 Thread r0g
John Machin wrote: > On Nov 22, 11:04 am, r0g <[EMAIL PROTECTED]> wrote: On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > Any help, pseudo code, or whatever push in the right direction would > be most appreciated. I am a novice Python programmer but I do hav

Re: Need help converting text to csv format

2008-11-22 Thread Chuck Connors
Firstly, I would like to thank those that offered help. I was able to get my data into the database and also have connectivity with the mysql and can pull the data in/out at will. Hooray and thanks again. Secondly, perhaps I overstated my abilities. I have written a couple of websites from scr

Re: Need help converting text to csv format

2008-11-22 Thread Thorsten Kampe
* Chuck Connors (Fri, 21 Nov 2008 08:10:09 -0800 (PST)) > Wow! What a change in direction from the previous post. Thank you > both for the help and the explanations. This will work great! No, it will not. For manipulating CSV data in Python you use the (*tada*) CSV module ("import csv"). The P

Re: Need help converting text to csv format

2008-11-22 Thread Steve Holden
John Machin wrote: > On Nov 22, 11:04 am, r0g <[EMAIL PROTECTED]> wrote: [...]>> If you can't muster even that level of enthusiasm or courtesy towards >> the noobs then you always have the option of not responding. > > Your "if X then Y" logic is somewhat cockeyed -- Y is true independent > of X.

Re: Need help converting text to csv format

2008-11-21 Thread John Machin
On Nov 22, 11:04 am, r0g <[EMAIL PROTECTED]> wrote: > >> On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > >>> 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 bi

Re: Need help converting text to csv format

2008-11-21 Thread alex23
On Nov 22, 2:28 am, Joe Strout <[EMAIL PROTECTED]> wrote: > A follow-up question here... is it really necessary to close things   > like files in Python? Not if you use a context manager (2.6+, available in 2.5 from __future__): with open('data.csv', 'wb') as csvfile: writer = csv.writer(csvfil

Re: Need help converting text to csv format

2008-11-21 Thread r0g
>> On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: >>> 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. John Machin wrote: > If

Re: Need help converting text to csv format

2008-11-21 Thread John Machin
On Nov 22, 7:38 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Nov 21, 2:01 pm, Richard Riley <[EMAIL PROTECTED]> wrote: > > > > > George Sakkis <[EMAIL PROTECTED]> writes: > > > On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > >> George Sakkis wrote: > > >> > On Nov 21, 10:18 am

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 2:01 pm, Richard Riley <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: > >> > On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > > >> >> Any help, pseudo code,

Re: Need help converting text to csv format

2008-11-21 Thread r0g
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: > > 40922003 Life Fitness Products $1 (12-13-

Re: Need help converting text to csv format

2008-11-21 Thread Richard Riley
George Sakkis <[EMAIL PROTECTED]> writes: > On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: >> George Sakkis wrote: >> > On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: >> >> >> Any help, pseudo code, or whatever push in the right direction would >> >> be most appreciate

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 11:05 am, Steve Holden <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > > >> 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

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 10:26 AM, MRAB wrote: The file will be closed automatically when the file object is garbage-collected. CPython uses reference-counting, so the file object is garbage- collected as soon as there are no references to it. Jython (and IronPython?) are garbage-collected in t

Re: Need help converting text to csv format

2008-11-21 Thread M.-A. Lemburg
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: > > 40922003 Life Fitnes

Re: Need help converting text to csv format

2008-11-21 Thread MRAB
Tim Golden wrote: Joe Strout wrote: A follow-up question here... is it really necessary to close things like files in Python? I've been slumming it in the REALbasic community for the last decade, where you generally don't worry about such things, as any object that represents something "open"

Re: Need help converting text to csv format

2008-11-21 Thread Tim Golden
Tim Chase wrote: yes, the CSV module has some wonderful stuff in it, and I regularly use it for *reading* CSV files. But for writing them, it's often just as fast (for my purposes) to simply code my 1st post's quickie as it is to scrounge in the docs/docstrings to remember how to let the CSV d

Re: Need help converting text to csv format

2008-11-21 Thread Tim Chase
Tim Golden wrote: Tim Chase wrote: >>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)] >>> out = qfields.join(',') Just a quick note here to prevent the confusion of the OP...this should be ','.join(qfields) To be honest, it's so easy to use the stdlib csv module that I'd

Re: Need help converting text to csv format

2008-11-21 Thread Tim Golden
Joe Strout wrote: A follow-up question here... is it really necessary to close things like files in Python? I've been slumming it in the REALbasic community for the last decade, where you generally don't worry about such things, as any object that represents something "open" will automatically

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 9:22 AM, Tim Golden wrote: Tim Chase wrote: >>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)] >>> out = qfields.join(',') Just a quick note here to prevent the confusion of the OP...this should be ','.join(qfields) Thanks Tim #1, for pointing out my er

Re: Need help converting text to csv format

2008-11-21 Thread Tim Golden
Tim Chase wrote: >>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)] >>> out = qfields.join(',') Just a quick note here to prevent the confusion of the OP...this should be ','.join(qfields) To be honest, it's so easy to use the stdlib csv module that I'd always recommend t

Re: Need help converting text to csv format

2008-11-21 Thread Chuck Connors
Wow! What a change in direction from the previous post. Thank you both for the help and the explanations. This will work great! -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help converting text to csv format

2008-11-21 Thread Tim Chase
>>> qfields = ['"' + fld.strip() + '"' for fld in (num,desc,date)] >>> out = qfields.join(',') Just a quick note here to prevent the confusion of the OP...this should be ','.join(qfields) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help converting text to csv format

2008-11-21 Thread Steve Holden
George Sakkis wrote: > On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > >> 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. > > I'm wondering if P

Re: Need help converting text to csv format

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 8:18 AM, Chuck Connors wrote: 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: 40922003 Life Fitnes

Re: Need help converting text to csv format

2008-11-21 Thread Tim Chase
40922003 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) i

Re: Need help converting text to csv format

2008-11-21 Thread Chuck Connors
> I'm wondering if PHP experience precludes the ability to use a search > engine before asking for help... Thanks for the push in the right direction, friend. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help converting text to csv format

2008-11-21 Thread George Sakkis
On Nov 21, 10:18 am, Chuck Connors <[EMAIL PROTECTED]> wrote: > 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. I'm wondering if PHP experience precludes the abil