-----Original Message----- From: RICHARD FERNANDEZ [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 2:04 PM To: beginners@perl.org Subject: RE: parsing a CSV file with more fields than column names
> > Hello Rich > > Hi, Chris, thanks for your response > > >> >> See docs for perlfunc, specifically split. >> >> Especially, the form for split >> 'split /PATTERN/,EXPR,LIMIT' >> >> By setting the limit, you will be able to solve the problem. >> >> Chris >> > The thing is I can't be sure that there will never be embedded commas in > the data (well maybe I can with this particular set of data, not sure), > so split (as discussed in the Cookbook) isn't the way to go. This is why > I was looking to use a specialized module for the job. Also, I need to > be able to address several of the fields specifically, to change their > values, so I like the idea of using a hash which is done for me with > something like Tie::Handle::CSV. > > <snip> If the data is as you showed, with no quotations around fields that contain commas, then you're screwed, unless you're talking about the last field only, in which case the split will work. If there may be commas inside of a comma-delimited output line then you will need some way to differentiate between a field that has a comma and one that doesn't. Are you SURE that there might be commas in the other fields? I would hope that whoever made this file you're parsing would have thought of this if they ever intended to later use the data. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>