I have a csv file that has some fields containing "," as part of the
field and not a delimiter. These fields are double quoted. What I
need to do is read each line, if the value in field 22 = X dont print
$line move
on to the next line. I am unable to use split to get the field I want
as some fields as I said are double quoted and contain "," in them.
example: "Potsdam, NY"
This one is driving me crazy.
I have only gotten about this far:
use Text::ParseWords;
while (@ARGV) {
$file=shift (@ARGV);
open (IN,"$file") unless ($file =~ /\.Z/);
while (defined($line = <IN>)) {
@fields =quotewords(',', 0, $line);
print "@fields[22]\n";
}
}
I have also tried the regex for csv files from Mastering Regex.
One thought was use a hash...
Any help or suggestions would be appreciated.
Thanks
As far as I know, Text::ParseWords is used to parse a line the way the
shell would see it. Not the same as CSV.
Try Text::CSV instead.
Paul Lalli