Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: swapping PIPE for comma in CSV file

by girarde (Hermit)
on Jun 26, 2007 at 15:15 UTC ( [id://623432]=note: print w/replies, xml ) Need Help??


in reply to swapping PIPE for comma in CSV file

I dunno, assuming that the quotes aren't still desired I'd split on /","/, join on |, and trim the trailing and leading quotes.

Maybe I'm missing something here.

Replies are listed 'Best First'.
Re^2: swapping PIPE for comma in CSV file
by Anonymous Monk on Jun 26, 2007 at 15:44 UTC
    A few people missed this (myself included). You have to split on a pair of double quotes or no quotes at all. There's the field with commas in it which you can't replace with a pipe so a simple regex or split/join won't work (at least without a massive regex on the split).
      Right, but I'm splitting on the 'quote, comma, quote' pattern, so embedded commas sail through. You can split on a pattern, although join wants a string.
        But what about the quote-comma-numbers transition?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found