Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: swapping PIPE for comma in CSV file

by Moron (Curate)
on Jun 27, 2007 at 10:23 UTC ( [id://623577]=note: print w/replies, xml ) Need Help??


in reply to swapping PIPE for comma in CSV file

I don't see why you can't just s/\",\"/\"|\"/g - embedded commas won't mess that up - even a single "," field won't mess up because the "," match at separator preceding it will take precedence and s/ will subsequently position after the executed substition at ,",", causing the next match to occur also at the correct place. (Update: Tested it now on "fred",",","bert" and it worked).

I am not going to jump on the "always use a module" bandwagon, because only the OPer can possibly know what the issues are surrounding that - I seem to have to keep saying it in here: it is unsafe to draw conclusions when potentially missing crucial information.

__________________________________________________________________________________

^M Free your mind!

  • Comment on Re: swapping PIPE for comma in CSV file

Replies are listed 'Best First'.
Re^2: swapping PIPE for comma in CSV file
by tirwhan (Abbot) on Jun 27, 2007 at 10:44 UTC
    I don't see why you can't just s/\",\"/\"|\"/g

    Perhaps you should have taken a better look at the data in the original node then, or read the several answers that detail why that won't work in this case! (Hint: there are unquoted numbers in the data). Honestly, posting an answer to a day-old thread without even reading the preceding answers seems a complete waste of everyones time.


    All dogma is stupid.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://623577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found