Need help converting text to csv format

John Machin sjmachin at lexicon.net
Fri Nov 21 23:57:20 EST 2008


On Nov 22, 11:04 am, r0g <aioe.... at technicalbloke.com> 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.
>
> <snip>
>
> John Machin wrote:
> > 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'm sure it doesn't, it doesn't to me either, but only because we
> already know what he needs! Do you think if the OP knew all about
> regular expressions and understood that python has a handy csv module
> that he'd be asking this question here?

(1) csv: The OP already knows what "csv" means -- see the subject
heading. Therefore expecting him to google("python csv") or something
similar before asking is quite reasonable.

(2) re: I don't and didn't expect the OP to "know all about regular
expressions". I did expect the OP to know that regular expressions
exist, based on the observations (a) many noobs seem to know a lot
about regular expressions [but don't know that they are not the best
option for parsing HTML and XML] (b) the OP stated "I do have a good
bit of PHP programming experience". Again, googling "python regular
expressions" or similar is a reasonable expectation.

> The OP is used to PHP, a fairly different kettle of fish. > Disgusting
> though PHP is it is many peoples first programming language, often in
> the unpleasant form of mod_php on a web server - clearly we are not
> dealing with a linux kernel hacker here.

Is a "linux kernel hacker" some superior form of being?

> I don't think it's at all unreasonable to come here and ask for "help,
> pseudo code, or whatever push in the right direction", and I certainly
> don't see a need to start questioning his credentails.

Possibly you meant "self reliance", not "credentials".

> He needs to know about the re and csv modules. A minimal yet polite
> response might have been: Go and google for the re and csv modules. You
> could have typed that, saved yourself a few hundred keystrokes and
> helped someone in the process.

By the time I replied, the OP had already been well and truly spoon-
fed far beyond that level.  I was merely concurring with George's
"blatantly obvious that they didn't put any effort whatsoever to find
an answer on their own" proposition.

> 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. Looking just at X: read some of my posts. You may find some with
a reasonable level of enthusiam and courtesy, especially where the
enquirer appears to have helped themselves to a reasonable extent
first and/or are having ESL difficulties and/or have not had a
response after 12 hours or more ...




More information about the Python-list mailing list