in reply to How can I read a file that is comma delimited but includes a comma in the string?
If another program is writing that file out, then you need to go to the author of that program and tell them to either learn how to create proper CSV files or pick a format that they can actually use. That line would typically have the last field quoted.
If it's always the case that the last field might have commas and the previous fields never have commas, you could do a restricted split:
my @fields = split ',', $data, 5;
I wouldn't do that, though, because you don't know what's going to change in the future. Whatever program you have creating the CSV data is writing bad data and you shouldn't have to put up with that.
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How can I read a file that is comma delimited but includes a comma in the string?
by Anonymous Monk on May 28, 2003 at 00:00 UTC | |
by Ovid (Cardinal) on May 28, 2003 at 00:13 UTC | |
by arturo (Vicar) on May 28, 2003 at 00:05 UTC |