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.