Need help converting text to csv format

John Machin sjmachin at lexicon.net
Fri Nov 21 22:16:55 CET 2008


On Nov 22, 7:38 am, George Sakkis <george.sak... at gmail.com> wrote:
> On Nov 21, 2:01 pm, Richard Riley <rileyrg... at gmail.com> wrote:
>
>
>
> > George Sakkis <george.sak... at gmail.com> writes:
> > > On Nov 21, 11:05 am, Steve Holden <st... at holdenweb.com> wrote:
> > >> George Sakkis wrote:
> > >> > On Nov 21, 10:18 am, Chuck Connors <don... at gmail.com> 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 ability to use a search
> > >> > engine before asking for help...
>
> > >> I'm wondering why you bothered to write that. Next time, save yourself
> > >> the ten seconds and just skip to the next message. The world will be a
> > >> better place.
>
> > > RTFM and doing an elementary search is an even better way to making
> > > the world a better place.
>
> > > George
>
> > So you will be replying in this tone to each and every question which
> > has an answer discoverable by Google and in depth knowledge of the "FM"
> > then I assume?
>
> No, only to those which is blatantly obvious that they didn't put any
> effort whatsoever to find an answer on their own; "python csv" has
> 1,420,000 hits in Google, the first one linking to the csv module
> docs.

If I had to write such a script in Python, I'd be using the re and csv
modules in similar fashion to responses already posted. If I had to
write it in PHP, it'd be my first PHP script, so let's go Googling:

google("php regex") first hit:
http://www.regular-expressions.info/php.html
[yuk, 3 different toolkits; 3rd is PCRE, let's try that]

google("php csv") 3rd hit points to:
http://www.php.net/manual/en/function.fputcsv.php

Doesn't seem too difficult to me.

I'd be interested to hear from the OP what is his level of experience
in PHP, how he would have approached the problem in PHP, and why he
didn't look for similar ways in Python.



More information about the Python-list mailing list