RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson
-Original Message- From: RICHARD FERNANDEZ [mailto:[EMAIL PROTECTED] Sent: Thursday, June 08, 2006 2:37 PM To: beginners@perl.org Subject: RE: parsing a CSV file with more fields than column names >> Are you SURE that there might be commas in the other fields? >> I wou

RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
> 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. Good point. But I have no way of verifying that. These CSV files are provided to me by an outside sou

RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson
-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 > > >>

RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
> 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 ne

RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson
As long as you're sure that there aren't any commas in your data, you could always do this: my @records = split(/,/,$line,17); This will limit your total records to 17, and will dump the rest into the 17th record. Then you can split the last record again if you want. If you have some comma

Re: parsing a CSV file with more fields than column names

2006-06-08 Thread Chris Charley
- Original Message - From: ""RICHARD FERNANDEZ"" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: Sent: Thursday, June 08, 2006 11:17 AM Subject: parsing a CSV file with more fields than column names Hello All, I'm just trying to get some ideas for the best way to approach this...