Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?

by MZSanford (Curate)
on Oct 31, 2001 at 22:44 UTC ( [id://122400]=note: print w/replies, xml ) Need Help??


in reply to parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?

You could use unpack similar to the following (as long as the fields are fixed width) :
my $data = qq!'a','b, and c','d '!; my ($a,undef,$b,undef,$c) = unpack("a3a1a10a1a3",$data);

If the fields are not fixed width, unpack may not be the bext way to go.
i had a memory leak once, and it ruined my favorite shirt.
  • Comment on Re: parsing CSV file with embedded commas (fortunately, fixed-width) - is unpack the solution?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found